# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440626 | MetalPower | Keys (IOI21_keys) | C++17 | 112 ms | 11160 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;
#include "keys.h"
struct disjoint_set{
int p[300005], sz[300005];
disjoint_set(){
for(int i = 0; i <= 300000; i++){
sz[i] = 1; p[i] = i;
}
}
int f(int x){
if(x == p[x]) return x;
else return p[x] = f(p[x]);
}
int ds(int x){
return sz[f(x)];
}
void Join(int u, int v){
int fu = f(u), fv = f(v);
if(fu == fv) return;
p[fu] = fv;
sz[fv] += sz[fu];
}
} dsu;
int node_size[300005];
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c){
bool all_zero = true;
int N = r.size(), M = u.size();
for(int j = 0; j < M; j++) dsu.Join(u[j], v[j]);
int mn = 1e9;
for(int i = 0; i < N; i++){
node_size[i] = (r[i] == 0 ? dsu.ds(i) : 1);
mn = min(mn, node_size[i]);
}
vector<int> ans(N);
for(int i = 0; i < N; i++) ans[i] = node_size[i] <= mn;
return ans;
}
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... |