Winning Strategy
Time limit8sMemory limit128 MB
For every start and goal pair, find the fewest rounds in which the chooser can force the token to the goal while the opponent picks inside each offered set.
- Level
Hard8 of 10
- Topics
- Game theory, Graph, BFS
- Solved
- No attempts yet
Problem
A monkey and a dog play a board game on named positions. Each round:
- The monkey chooses one option, a set of positions the dog may move to.
- The dog picks one position from that set and moves the token there.
Before play, the monkey picks the goal position and the dog picks the start. The monkey wins if the token reaches the goal. The monkey pays the dog each round, so failure to win eventually bankrupts the monkey.
Both play optimally. For every start and goal , find the minimum number of rounds for the monkey to guarantee a win, or if impossible.
Input
The first line has (). Positions use the first lowercase letters.
Each of the next lines describes one position: option count () followed by strings, each a sorted set of letters the dog may choose from on that option.
Output
Print lines. Line lists, in position order, the minimum winning rounds from start to each goal, or when the monkey cannot force a win.