제출 #304630

#제출 시각아이디문제언어결과실행 시간메모리
304630dolijanBosses (BOI16_bosses)C++14
100 / 100
798 ms760 KiB
#include <bits/stdc++.h> using namespace std; const int mn=5069; vector<vector<int> > graf(mn); int kolko=0; int bfs(int node,int n) { bool visited[n+1]; int level[n+1]; for(int i=1;i<=n;i++) visited[i]=false; queue<int> q; q.push(node); visited[node]=true; int rez=0; level[node]=1; while(!q.empty()) { int t=q.front(); q.pop(); rez+=level[t]; kolko++; for(int i=0;i<graf[t].size();i++) { if(!visited[graf[t][i]]) { q.push(graf[t][i]); level[graf[t][i]]=level[t]+1; visited[graf[t][i]]=true; } } } return rez; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int k; cin>>k; int inp; for(int j=0;j<k;j++) { cin>>inp; graf[inp].push_back(i); } } int mn=n*n; for(int i=1;i<=n;i++) { kolko=0; int sta=bfs(i,n); //cout<<i<<" "<<kolko<<endl; if(kolko==n) { //cout<<i<<sta<<endl; mn=min(mn,sta); } } cout<<mn<<endl; }

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

bosses.cpp: In function 'int bfs(int, int)':
bosses.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i=0;i<graf[t].size();i++)
      |                     ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...