#P8371. [POI 2001 R1] 绿色游戏
[POI 2001 R1] 绿色游戏
Problem Description
Green Game is a two-player game. The two players are called and . The game consists of moving a single token on a board in turns.
Some points on the board are green, and the rest are white. All points are numbered from to . Points numbered to belong to , and points numbered to belong to . Each point has some successor points that can be reached in one move. The successors of a point belonging to must belong to , and vice versa. Every point has at least one successor point, so it is always possible to move one step forward.
At the start of the game, the token is placed on an arbitrary point . Then the players alternately move the token from the current point (which belongs to the player whose turn it is) to one of its successor points (which belongs to the opponent). The owner of point moves first. The game ends when the token reaches some point for the second time; call this point . If, during the sequence of moves from point back to point , the token is placed on a green point at least once, then wins. If, starting from point , no matter how moves, can always guarantee winning the game, then we say that has a winning strategy for the starting point .
Write a program to:
-
Read the description of the board.
-
Determine all starting points for which has a winning strategy.
Input Format
The first line contains two integers and , separated by a single space, representing the numbers of points belonging to and , respectively . The next lines describe the points, first all of 's points, then all of 's points.
Line starts with integers : denotes the color of point ( for white, for green), and denotes the number of successor points. Then follow integers on the same line, giving the indices of the successor points, separated by single spaces. The number of green points does not exceed , and the sum of the numbers of successor points over all points does not exceed .
Output Format
The first line contains a single integer , the number of starting points for which has a winning strategy. The next lines list these point indices in increasing order, one per line.
5 3
0 2 6 7
0 3 6 7 8
0 1 8
1 1 7
1 1 8
1 2 1 2
0 2 1 2
0 2 3 4
5
1
2
4
6
7
Hint
Translated by ChatGPT 5