cf
/
mirror
Problemset
Contests
Favorites
Profile
Tools
Settings
Problemset
Contests
Favorites
Profile
Complexity
Stress
Graph
Templates
Crawler
Network Safety
☆
save
CF
1039C
⊞ graph
2200
· master
3s
512 MB
⌨ stdin/stdout
#dfs and similar
#dsu
#graphs
#math
#sortings
hide
Examples
Sample 1
of 2
Input
copy
4 4 2
0 1 0 1
1 2
2 3
3 4
4 1
Output
copy
50
Sample 2
of 2
Input
copy
4 5 3
7 1 7 2
1 2
2 3
3 4
4 1
2 4
Output
copy
96
58%
1039C.cpp
GNU C++20 (64)
GNU C11
Python 3
PyPy 3
Java 21
Rust
Go
C#
JavaScript
Ruby
Pascal
Haskell
Kotlin · no run
loading editor…
Ln
11
·
137 B
GNU C++20 (64)
⟲ Reset
Run samples
Submit
▸
Custom test
run your code against any stdin
▸
Stress test
run a brute + generator against your solution to find a failing case
▾
Graph visualizer
paste edges (or use sample) — auto-detects trees / DAGs / weighted graphs ·
g g
to open
loading graph engine…
▸
Editorial & videos
official tutorial + youtube — hidden while contest is live