#P1992. 不想兜圈的老爷爷
不想兜圈的老爷爷
Description
Task 1
Given a directed graph with vertices and edges, determine whether the graph has no cycles.
Task 2.1
Given an integer , compute .
Task 2.2
Given an integer , compute , and the answer does not need to be taken modulo anything.
Input Format
The first line contains three integers .
The next lines each contain two positive integers , indicating a directed edge .
Output Format
Task 1
If there are indeed no cycles (no cycles), output one line containing the string Yes.
If it is not the case that there are no cycles (there is a cycle), output one line containing the string No.
Task 2.1
If the answer to Task 1 is No, then ignore this task and output nothing.
If the answer to Task 1 is Yes, then (after outputting the answer to Task 1) output one line containing an integer for the answer.
Task 2.2
If the answer to Task 1 is Yes, then ignore this task and output nothing.
If the answer to Task 1 is No, then (after outputting the answer to Task 1) output one line containing an integer for the answer.
3 3 3
1 2
2 3
3 1
No
9
Hint
For 70% of the testdata, , , .
For 100% of the testdata, , , .
In particular, for at least 20% of the testdata, the answer to Task 1 is No.
Translated by ChatGPT 5
京公网安备 11011102002149号