#P10525. [XJTUPC 2024] 图上操作

[XJTUPC 2024] 图上操作

Problem Description

You are given a directed graph with nn vertices and mm edges, where the vertices are numbered from 11 to nn. Each edge has a positive integer weight did_i. In particular, 1di1001\le d_i \le 100.

Now define the bottleneck path value of vertex ii as follows: among all directed paths from vertex 11 to vertex ii, take the minimum edge weight on each path, and then take the maximum of these minimum values. In particular, if ii is not reachable from 11, then its bottleneck path value is 00.

There are qq modifications. Each modification specifies an edge and decreases its weight, and it is guaranteed that the weight is still a positive integer after the decrease.

After each modification, output the bottleneck path values of vertices 2n2\sim n. Note that each modification is applied on top of all previous modifications; they are not independent.

Since the output is too large, let the bottleneck path value of vertex ii after a modification be ansians_i. You only need to output (i=2nansi×2i)mod998244353(\sum_{i=2}^n ans_i \times 2^i)\bmod 998244353 after each modification.

Input Format

The first line contains three positive integers n,m,qn,m,q (2n1×1052\le n\le 1\times 10^51m2×1051\le m \le 2\times 10^51q2×1051\le q\le 2\times 10^5), separated by spaces, with the meanings as described above.

The next mm lines each contain three positive integers si,ti,dis_i,t_i,d_i (1si,tin1\le s_i,t_i\le nsitis_i\neq t_i1di1001\le d_i \le 100), separated by spaces, indicating that there is a directed edge from sis_i to tit_i with weight did_i. The index of this edge is ii. It is guaranteed that there are no self-loops, but there may be multiple edges.

The next qq lines each contain two positive integers x,yx,y (1xm1\le x\le m1y<dx1\le y < d_x), separated by spaces, indicating that the weight of edge xx is decreased by yy, and it is guaranteed that the resulting weight is greater than 00.

Output Format

Output qq lines, each containing one non-negative integer, which is the answer you computed.

3 3 4
1 2 3
2 3 4
1 3 5
3 1
3 2
1 2
2 3

44
36
20
20

Hint

After the first modification, the bottleneck path value of vertex 22 is 33, and the bottleneck path value of vertex 33 is 44.

After the second modification, the bottleneck path value of vertex 22 is 33, and the bottleneck path value of vertex 33 is 33.

After the third modification, the bottleneck path value of vertex 22 is 11, and the bottleneck path value of vertex 33 is 22.

After the fourth modification, the bottleneck path value of vertex 22 is 11, and the bottleneck path value of vertex 33 is 22.

Translated by ChatGPT 5