I've struggled some time with a problem from a programming contest (Andrew Stankevich Contest 21) about a game that goes like follows:
Nick and Peter like to play the following game [...]. They draw an undirected bipartite graph G on a sheet of paper, and put a token to one of its vertices. After that they make moves in turn. Nick moves first.
A move consists of moving the token along the graph edge. After it the vertex where the token was before the move, together with all edges incident to it, are removed from the graph. The player who has no valid moves loses the game.
The graph is given and the task now is to find for a given start node, whether the starting player wins or loses if both players play optimally. To summarize
- Bipartite graph
- We are given the start node (say on the left side)
- We move in turns, a move consists of following an edge, but we can't visit a node that was already visited
- The player who cannot move loses
Since the graph is bipartite, Nick (the first player) will always remove a node from the left side and Peter will always remove a node from the right side.
The graph can have up to 1000 nodes (at most 500 at each side) and 50000 edges, so a good polynomial time algorithm is needed (the time limit here is 2 seconds to solve all starting positions, but I think we can share a lot of information between the different starting positions).
I'm pretty sure that this can be reduced to some kind of vertex covering or packing problem, because the graph is bipartite, but I can't find a strategy that correlates to any of these.
I know the solution for a special case: Let's say the sides have n1 and n2 vertices, respectively. If there is a matching of size min(n1, n2) and if the player on the smaller side begins, than there exists a winning strategy: He just has to follow the matched edges and automatically wins.
Any ideas?