#P7955. Formation Feasibility
Formation Feasibility
Formation Feasibility
The coach has several formation schemes of the form O-V-N where O, V, and N represent the number of defensive players, midfield players, and attacking players respectively. Note that the sum must always be \(O + V + N = 10\).
There are \(m\) players available. Each player can play in one or more positions among O
, V
, and N
. For each formation scheme provided by the coach, determine whether it is possible to assign different players to the 10 positions so that every required slot is filled by a player who is capable of playing that position. Each player can be used at most once.
inputFormat
The input begins with an integer \(m\) representing the number of players. The following \(m\) lines each contain a non-empty string composed of the characters O
, V
, and/or N
, indicating the positions that the player can play (for example, OV
means the player can play in defense (O
) or midfield (V
)).
The next line contains an integer \(t\) representing the number of formation schemes. Then, \(t\) lines follow, each containing three integers: \(O\), \(V\), and \(N\) (with \(O + V + N = 10\)), describing one formation scheme.
outputFormat
For each formation scheme, output a single line containing YES
if it is possible to assign players to meet the formation requirements, or NO
otherwise.
sample
10
O
V
N
OV
ON
VN
OV
V
N
OVN
1
3 3 4
YES
</p>