Logo
(追記) (追記ここまで)

23461번 - All Pair Maximum Flow 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 (추가 시간 없음) 256 MB11107100.000%

문제

You are given an undirected graph. You want to compute the maximum flow from each vertex to every other vertex.

The graph is special. You can regard it as a convex polygon with $n$ points (vertices) and some line segments (edges) connecting them. The vertices are labeled from 1ドル$ to $n$ in the clockwise order. The line segments can only intersect each other at the vertices.

Each edge has a capacity constraint.

Denote the maximum flow from $s$ to $t$ by $f(s,t)$. Output $\left(\sum_{s=1}^n \sum_{t=s+1}^n f(s,t) \right) \bmod 998244353$.

입력

The first line contains two integers $n$ and $m,ドル representing the number of vertices and edges (3ドル\le n\le 200000, n\le m\le 400000$).

Each of the next $m$ lines contains three integers $u, v, w$ denoting the two endpoints of an edge and its capacity (1ドル\le u, v\le n, 0\le w\le 1000000000$).

It is guaranteed there are no multiple edges and self-loops.

It is guaranteed that there is an edge between vertex $i$ and vertex $(i\bmod n)+1$ for all $i=1,2,\ldots, n$.

출력

Output the answer in one line.

제한

예제 입력 1

6 8
1 2 1
2 3 10
3 4 100
4 5 1000
5 6 10000
6 1 100000
1 4 1000000
1 5 10000000

예제 출력 1

12343461

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 10: Grand Prix of Xi’An K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /