Submission #450525

#TimeUsernameProblemLanguageResultExecution timeMemory
450525leinad2Keys (IOI21_keys)C++17
0 / 100
1 ms460 KiB
#include "keys.h" #include<bits/stdc++.h> using namespace std; vector<pair<int, int> >adj[2010]; vector<int>find_reachable(vector<int>r, vector<int>u, vector<int>v, vector<int>c) { int n=r.size();int m=u.size();int i, j, k; for(i=0;i<m;i++) { adj[u[i]].push_back({v[i], c[i]}); adj[v[i]].push_back({u[i], c[i]}); } vector<int>ans;ans.resize(n); for(i=0;i<n;i++) { int chk[2010]={}, A[2010]={};vector<int>v; v.push_back(i);chk[i]=1;A[r[i]]=1; while(1) { bool flag=false; for(auto j:v) { for(auto k:adj[j]) { if(A[k.second]==1&&chk[k.first]==0) { chk[k.first]=1; A[r[k.first]]=1; v.push_back(k.first); flag=true; } } } if(flag==false)break; } for(j=0;j<n;j++)ans[i]+=chk[j]; } int x=1e9; for(i=0;i<n;i++)x=min(ans[i], x); for(i=0;i<n;i++)ans[i]=(ans[i]==x); 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:7:42: warning: unused variable 'k' [-Wunused-variable]
    7 |  int n=r.size();int m=u.size();int i, j, k;
      |                                          ^
#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...