#P10746. [SEERC 2020] Codenames
[SEERC 2020] Codenames
Problem Description
There are boards. For each cell, its color is given (only r, b, n, x are possible). The color distribution is: r, b, n, and x.
The character corresponding to each cell on the board is fixed as follows:
abcde
fghij
klmno
pqrst
uvwxy
On the board, some colors have already been revealed (a revealed cell is shown using the uppercase letter of its color). Then you need to choose a string from a list of strings and a number , and perform the following operation times.
- If the cell corresponding to the current character has already been revealed, do nothing and set .
- Otherwise, reveal the cell corresponding to . If the color of is
n,b, orx, you lose. Then set . - Stop when operations are completed or when all
rcells have been revealed.
You want to reveal all r cells. Find a pair that satisfies this requirement.
Input Format
The first line contains an integer .
Then follow lines, each containing a string, describing the whole list of strings.
Line contains an integer , the number of boards.
Then follow boards, each of size , describing the colors of the -th board.
Output Format
For each board, if there is a solution, output one valid and . If there is no solution, output IMPOSSIBLE.
3
actor
cheat
zeta
1
rBBnR
NRnbB
nRRnR
NRxBr
nBRbB
actor 2
Hint
The answer could also be actor 4, zeta 2, etc.
Translated by ChatGPT 5