제출 #450528

#제출 시각아이디문제언어결과실행 시간메모리
450528leinad2열쇠 (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 x:v) { for(auto y:adj[x]) { if(A[y.second]==1&&chk[y.first]==0) { chk[y.first]=1; A[r[y.first]]=1; v.push_back(y.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; }

컴파일 시 표준 에러 (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...