#P10682. [COTS 2024] 奇偶南瓜 Tikvani
[COTS 2024] 奇偶南瓜 Tikvani
Background
Translated from Izborne Pripreme 2024 (Croatian IOI/CEOI Team Selection) D1T3。。
Problem Description
Given a directed graph , where , it satisfies that for all , we have 。
Define an edge coloring scheme as a way to assign a weight to each edge. Let the weight of edge be 。
Define a path from node to node as a sequence such that , and for all , we have 。Define the weight of a path as the sum of the weights of all edges on it, i.e., 。
A coloring scheme is called good if and only if for every pair , the remainders modulo of the weights of all paths between are the same.
Compute the number of good coloring schemes, modulo 。
Input Format
The first line contains two positive integers , with meanings as described above。
The next lines each contain two positive integers , indicating 。
Output Format
Output one line with one integer, representing the result modulo 。
4 4
1 2
2 3
3 4
1 4
8
4 4
1 3
1 4
2 3
2 4
16
Hint
Sample Explanation
Explanation for sample : Obviously, only between and are there two paths 。
When , on the path you can only choose or edges whose weights are , so the number of schemes is ;
When , on the path you can only choose or edges whose weights are , so the number of schemes is 。
Therefore, the answer is 。
Constraints
For of the testdata, it is guaranteed that:
- ,;
- 。
| Subtask ID | Score | Constraints |
|---|---|---|
| No additional constraints |
Translated by ChatGPT 5