#P1343. 地震逃生

    ID: 340 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索图论福建省历届夏令营最大流

地震逃生

Description

When the Wenchuan earthquake struck, Sichuan ** High School was in class. As soon as the earthquake occurred, the teachers immediately led xx students to evacuate. The whole school can be abstracted as a directed graph with nn nodes and mm edges. Node 11 is the classroom, and node nn 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 11. 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 xx students.

Input Format

The first line contains three integers n,m,xn, m, x.
The next mm lines each contain three integers a,b,ca, b, c (1a,bn1 \le a, b \le n, 0cx0 \le c \le x), describing an edge: there is an edge from node aa to node bb that can accommodate cc students.

Output Format

If it is impossible to reach the destination (node nn), 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 xx 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

100100 students first rush to node 22, and then go along edge 232 \to 3 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 100%100\% of the testdata, 0x<2310 \le x < 2^{31}, 2n2002 \le n \le 200, 1m20001 \le m \le 2000.

Translated by ChatGPT 5