제출 #717873

#제출 시각아이디문제언어결과실행 시간메모리
717873blackslexBosses (BOI16_bosses)C++17
100 / 100
743 ms636 KiB
#include<bits/stdc++.h> using namespace std; const int N = 5005; int n, m, x, ans = INT_MAX; vector<int> v[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &m); while (m--) scanf("%d", &x), v[x].emplace_back(i); } for (int i = 1; i <= n; i++) { int d[N] = {}, res = 0; queue<int> q; bool f = 0; d[i] = 1, q.emplace(i); while (!q.empty()) { int cur = q.front(); q.pop(); for (auto &e: v[cur]) if (!d[e]) d[e] = d[cur] + 1, q.emplace(e); } for (int j = 1; j <= n; j++) res += d[j], f = (!d[j] ? 1 : f); if (!f) ans = min(ans, res); } printf("%d", ans); }

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

bosses.cpp: In function 'int main()':
bosses.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bosses.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d", &m);
      |         ~~~~~^~~~~~~~~~
bosses.cpp:13:26: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         while (m--) scanf("%d", &x), v[x].emplace_back(i);
      |                     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...