# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771230 | siewjh | Bridges (APIO19_bridges) | C++17 | 3035 ms | 6504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> iii;
const int MAXN = 50005;
int par[MAXN], sz[MAXN];
vector<pair<int, int>> jst;
int root(int x){
if (par[x] == -1) return x;
else return root(par[x]);
}
void join(int a, int b){
int ra = root(a), rb = root(b);
if (ra == rb) return;
if (sz[ra] < sz[rb]) swap(ra, rb); // ra larger
par[rb] = ra;
sz[ra] += sz[rb];
jst.push_back({ra, rb});
}
void rollback(){
while (!jst.empty()){
int ra, rb; tie(ra, rb) = jst.back(); jst.pop_back();
par[rb] = -1;
sz[ra] -= sz[rb];
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int nodes, edges; cin >> nodes >> edges;
vector<pair<int, int>> elist(edges + 1);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |