# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024215 | Abito | Keys (IOI21_keys) | C++17 | 57 ms | 15440 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;
const int N=3e5+5;
int sz[N],par[N],p[N],c[N],r[N],n;
int getpar(int x){
if (x==par[x]) return x;
return par[x]=getpar(par[x]);
}
void link(int x,int y){
x=getpar(x);
y=getpar(y);
if (x==y) return;
if (sz[x]>sz[y]) swap(x,y);
sz[y]+=sz[x];
par[x]=y;
return;
}
std::vector<int> find_reachable(std::vector<int> R, std::vector<int> U, std::vector<int> V, std::vector<int> C) {
n=R.size();
vector<int> ans(n);
for (int i=0;i<n;i++) sz[i]=1,par[i]=i;
for (int i=0;i<U.size();i++) link(U[i],V[i]);
int mn=INT_MAX;
for (int i=0;i<n;i++){
if (R[i]) mn=1;
else mn=min(mn,sz[getpar(i)]);
}
for (int i=0;i<n;i++){
if (R[i]) ans[i]=1;
else ans[i]=bool(sz[getpar(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... |