Samples
To easily test your code from samples, copy and paste the following main function to the bottom of your code.
C++
int main() {int n, q;cin >> n >> q;Init(n);for (int i = 0; i < q; i++) {int t;cin >> t;if (t == 1) {int u, v;cin >> u >> v;
Input:
5 10 1 1 2 3 1 1 2 3 3 2 1 3 4 3 3 1 4 5 3 4 2 3 1
Expected Output:
2 3 4 5 4
Implementation
This is a standard test of your DSU with rollback template.
C++
#include <bits/stdc++.h>using namespace std;Code Snippet: DSU (from the module) (Click to expand)const int MAXN = 500000;DSU dsu(MAXN);void Init(int n) {}
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!