Implementation
Time Complexity:
C++
Interestingly, the following code passes all test cases but won't pass if ; you'd have to make a separate edge case for that.
#include <bits/stdc++.h>using namespace std;using ll = long long;struct Edge {int u, v, w;};struct DSU {vector<int> p, sz, unprocessed_starts;
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!