제출 #450530

#제출 시각아이디문제언어결과실행 시간메모리
450530leinad2열쇠 (IOI21_keys)C++17
37 / 100
1490 ms20844 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(j=0;j<v.size();j++) { int a=v[j]; for(auto k:adj[a]) { 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; }

컴파일 시 표준 에러 (stderr) 메시지

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             for(j=0;j<v.size();j++)
      |                     ~^~~~~~~~~
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...