제출 #537855

#제출 시각아이디문제언어결과실행 시간메모리
537855GurbanBosses (BOI16_bosses)C++17
0 / 100
1 ms340 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; const int maxn=5e3+5; int n; int dis[maxn]; vector<int>E[maxn]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1;i <= n;i++){ int sz; cin >> sz; for(int j = 0;j < sz;j++){ int p; cin >> p; E[p].push_back(i); } } queue<int>q; int ans = 1e9; for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++) dis[j] = 1e9; dis[i] = 1; q.push(i); while(!q.empty()){ int x = q.front(); q.pop(); for(auto j : E[x]){ if(dis[j] > dis[x] + 1){ dis[j] = dis[x] + 1; q.push(j); } } } bool tr = 0; int nw = 0; for(int j = 1;j <= n;j++){ if(dis[j] == 1e9){ tr = 1; break; } nw += dis[j]; } ans = min(ans,nw); } cout<<ans; } /* 4 1 4 3 1 3 4 2 1 2 1 3 */

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

bosses.cpp: In function 'int main()':
bosses.cpp:39:8: warning: variable 'tr' set but not used [-Wunused-but-set-variable]
   39 |   bool tr = 0;
      |        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...