Submission #1024215

#TimeUsernameProblemLanguageResultExecution timeMemory
1024215AbitoKeys (IOI21_keys)C++17
9 / 100
57 ms15440 KiB
#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)

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:22:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for (int i=0;i<U.size();i++) link(U[i],V[i]);
      |               ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...