# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367477 | Jarif_Rahman | Bridges (APIO19_bridges) | C++17 | 3079 ms | 12216 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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
struct dsu{
stack<tuple<int, int, int>> st;
int n;
vector<int> id;
vector<vector<int>> comp;
dsu(int nn){
n = nn;
for(int i = 0; i < n; i++) id.pb(i), comp.pb({i});
}
int unite(int a, int b){
a = id[a], b = id[b];
if(a == b) return 0;
if(comp[a].size() > comp[b].size()) swap(a, b);
st.push({a, b, (int)comp[a].size()});
while(!comp[a].empty()){
int x = comp[a].back(); comp[a].pop_back();
id[x] = b;
comp[b].pb(x);
}
return 1;
}
void rollback(){
auto [a, b, sz] = st.top(); st.pop();
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... |