atcoder#AGC016F. [AGC016F] Games on DAG
[AGC016F] Games on DAG
Score : points
Problem Statement
There is a directed graph with vertices and edges. The vertices are numbered through , and the edges are numbered through . Edge is directed from to . Here, holds. Also, there are no multiple edges in .
Consider selecting a subset of the set of the edges in , and removing these edges from to obtain another graph . There are different possible graphs as .
Alice and Bob play against each other in the following game played on . First, place two pieces on vertices and , one on each. Then, starting from Alice, Alice and Bob alternately perform the following operation:
- Select an edge such that there is a piece placed on vertex , and move the piece to vertex (if there are two pieces on vertex , only move one). The two pieces are allowed to be placed on the same vertex.
The player loses when he/she becomes unable to perform the operation. We assume that both players play optimally.
Among the different possible graphs as , how many lead to Alice's victory? Find the count modulo .
Constraints
- All are distinct.
Input
Input is given from Standard Input in the following format:
Output
Print the number of that lead to Alice's victory, modulo .
2 1
1 2
1
The figure below shows the two possible graphs as . A graph marked with ○ leads to Alice's victory, and a graph marked with × leads to Bob's victory.
3 3
1 2
1 3
2 3
6
The figure below shows the eight possible graphs as .
4 2
1 3
2 4
2
5 10
2 4
3 4
2 5
2 3
1 2
3 5
1 3
1 5
4 5
1 4
816