제출 #368055

#제출 시각아이디문제언어결과실행 시간메모리
368055leinad2Bosses (BOI16_bosses)C++17
100 / 100
843 ms748 KiB
#include<bits/stdc++.h> using namespace std; vector<int>adj[5010]; int n, i, j, k, a, b, ans=1e9; int main() { ios_base::sync_with_stdio(!cin.tie(NULL)); for(cin>>n;i++<n;) { cin>>a; while(a--) { cin>>b; adj[b].push_back(i); } } for(i=0;i++<n;) { int dist[5010]={}; dist[i]=1; queue<int>q; q.push(i); while(q.size()) { a=q.front(); q.pop(); for(j=0;j<adj[a].size();j++) { if(!dist[adj[a][j]]) { dist[adj[a][j]]=dist[a]+1; q.push(adj[a][j]); } } } int ret=0; for(j=0;j++<n;) { if(dist[j]==0)goto w; ret+=dist[j]; } ans=min(ans, ret); w:; } cout<<ans; }

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

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