제출 #98340

#제출 시각아이디문제언어결과실행 시간메모리
98340KastandaBosses (BOI16_bosses)C++11
100 / 100
545 ms768 KiB
#include<bits/stdc++.h> #define pb push_back using namespace std; const int N = 5005; int n, Mn = INT_MAX, D[N], qu[N]; vector < int > Adj[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { int len, a; scanf("%d", &len); for (; len; len --) scanf("%d", &a), Adj[a].pb(i); } for (int i = 1; i <= n; i++) { int l = 0, r = 0; int sum = 0, cnt = 0; memset(D, -1, sizeof(D)); qu[r ++] = i; D[i] = 1; while (r - l) { int v = qu[l ++]; sum += D[v]; cnt ++; for (int &u : Adj[v]) if (D[u] == -1) qu[r ++] = u, D[u] = D[v] + 1; } if (cnt == n) Mn = min(Mn, sum); } return !printf("%d\n", Mn); }

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

bosses.cpp: In function 'int main()':
bosses.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
bosses.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &len);
         ~~~~~^~~~~~~~~~~~
bosses.cpp:15:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a), Adj[a].pb(i);
             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...