제출 #121571

#제출 시각아이디문제언어결과실행 시간메모리
121571DodgeBallManBosses (BOI16_bosses)C++14
100 / 100
571 ms760 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 5e3 + 10; int n, ans = INT_MAX; vector<int> g[N]; int dep[N]; queue<int> q; int bfs( int root ) { int ret = 0; for( int i = 1 ; i <= n ; i++ ) dep[i] = INT_MAX; dep[root] = 1; q.emplace( root ); while( !q.empty() ) { int now = q.front(); q.pop(); for( int i : g[now] ) if( dep[now] + 1 < dep[i] ) { dep[i] = dep[now] + 1; q.emplace( i ); } } for( int i = 1 ; i <= n ; i++ ) { if( dep[i] == INT_MAX ) return INT_MAX; ret += dep[i]; } return ret; } int main() { scanf("%d",&n); for( int i = 1, k ; i <= n ; i++ ) { scanf("%d",&k); for( int j = 1, t ; j <= k ; j++ ) { scanf("%d",&t); g[t].emplace_back( i ); } } for( int i = 1 ; i <= n ; i++ ) ans = min( ans, bfs( i ) ); printf("%d",ans); return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bosses.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
bosses.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&t);
             ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...