제출 #208089

#제출 시각아이디문제언어결과실행 시간메모리
208089kai824Bosses (BOI16_bosses)C++17
100 / 100
959 ms760 KiB
#include "bits/stdc++.h" using namespace std; #define int long long int n,k,a,ans=INT_MAX; int dist[5005]; int cur,nodes; vector<int> children[5005]; int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0); queue<int> bfs; cin>>n; for(int x=1;x<=n;x++){ cin>>k; while(k--){ cin>>a; children[a].emplace_back(x); } } for(int x=1;x<=n;x++){ for(int i=1;i<=n;i++){ dist[i]=INT_MAX; } bfs.emplace(x);dist[x]=cur=1; nodes=0; while(!bfs.empty()){ nodes++; a=bfs.front(); bfs.pop(); for(int i=0;i<children[a].size();i++){ if(dist[children[a][i]]==INT_MAX){ dist[children[a][i]]=dist[a]+1; cur+=dist[a]+1; bfs.emplace(children[a][i]); } } } if(nodes!=n)continue; ans=min(ans,cur); } cout<<ans<<'\n'; return 0; }

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

bosses.cpp: In function 'int32_t main()':
bosses.cpp:33:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<children[a].size();i++){
                     ~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...