Submission #894859

#TimeUsernameProblemLanguageResultExecution timeMemory
894859Muhammad_AneeqKeys (IOI21_keys)C++17
37 / 100
3028 ms40900 KiB
#include <vector> using namespace std; int const N=3e5+10; vector<pair<int,int>>nei[N]={}; int key[N]={}; int viskey[N]={}; int vis[N]={}; vector<int>req[N]={}; bool w=0; void dfs(int n) { vis[n]=1; viskey[key[n]]=1; for (auto i:req[key[n]]) if (!vis[i]) dfs(i); for (auto [i,w]:nei[n]) { if (vis[i]) continue; if (viskey[w]==0) req[w].push_back(i); else dfs(i); } } vector<int> find_reachable(vector<int> r,vector<int> u,vector<int> v,vector<int> c) { int n=r.size(); for (int i=0;i<u.size();i++) { nei[u[i]].push_back({v[i],c[i]}); nei[v[i]].push_back({u[i],c[i]}); } for (int i=0;i<n;i++) key[i]=r[i]; vector<int>f={}; for (int i=0;i<n;i++) { for (int j=0;j<n;j++) { req[j]={}; vis[j]=viskey[j]=0; } w=(i==5); dfs(i); int t=0; for (int j=0;j<n;j++) t+=vis[j]; f.push_back(t); } vector<int>ans={}; int z=n; for (auto i:f) z=min(z,i); for (auto i:f) ans.push_back((z==i?1:0)); 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:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i=0;i<u.size();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...