Submission #443376

#TimeUsernameProblemLanguageResultExecution timeMemory
443376leinad2Keys (IOI21_keys)C++17
37 / 100
1775 ms17092 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, i, j, k, m, a, b; n=r.size();m=c.size(); vector<int>ans; ans.resize(n); for(i=0;i<m;i++) { adj[u[i]].push_back({v[i], c[i]}); adj[v[i]].push_back({u[i], c[i]}); } for(i=0;i<n;i++) { int chk[2010]={}, A[2010]={}; chk[i]=1;A[r[i]]=1;vector<int>v;v.push_back(i); while(1) { bool flag=false; for(j=0;j<v.size();j++) { a=v[j]; for(k=0;k<adj[a].size();k++) { if(A[adj[a][k].second]==1&&chk[adj[a][k].first]==0) { chk[adj[a][k].first]=1; A[r[adj[a][k].first]]=1; v.push_back(adj[a][k].first); flag=true; } } } if(!flag)break; } for(j=0;j<n;j++)ans[i]+=chk[j]; } int x=1e9;for(i=0;i<n;i++)x=min(x, ans[i]); 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:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             for(j=0;j<v.size();j++)
      |                     ~^~~~~~~~~
keys.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 for(k=0;k<adj[a].size();k++)
      |                         ~^~~~~~~~~~~~~~
keys.cpp:7:27: warning: unused variable 'b' [-Wunused-variable]
    7 |     int n, i, j, k, m, a, b;
      |                           ^
#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...