#P1343. 地震逃生
地震逃生
Description
When the Wenchuan earthquake struck, Sichuan ** High School was in class. As soon as the earthquake occurred, the teachers immediately led students to evacuate. The whole school can be abstracted as a directed graph with nodes and edges. Node is the classroom, and node is the safe zone. Each edge can only accommodate a certain number of students; if exceeded, the building would collapse. Due to the large number of people, the principal decided to evacuate in several batches. Only after the first batch has completely evacuated may the second batch start from node . Please help the principal calculate the maximum number of students that can be transported in each batch, and how many batches are needed to transport all students.
Input Format
The first line contains three integers .
The next lines each contain three integers (, ), describing an edge: there is an edge from node to node that can accommodate students.
Output Format
If it is impossible to reach the destination (node ), output Orz Ni Jinan Saint Cow!. Otherwise, output two integers: the maximum number of students that can be transported in each batch, and the number of batches needed to transport all students.
6 7 7
1 2 1
1 4 2
2 3 1
4 5 1
4 3 1
3 6 2
5 6 1
3 3
Hint
[Note]
For example, consider the graph
1 2 100
2 3 1
students first rush to node , and then go along edge one by one.
According to the 2018 "Shen Niu" rules, this is not allowed.
In other words, each batch of students must depart from the source simultaneously and arrive at the sink simultaneously.
[Constraints]
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号