제출 #79529

#제출 시각아이디문제언어결과실행 시간메모리
79529FutymyCloneBosses (BOI16_bosses)C++14
100 / 100
700 ms1020 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e3 + 5; vector <int> g[N]; bool visited[N]; int val[N], n, ans = 1e9; void bfs (int s) { queue <int> q; q.push(s); visited[s] = true; while (!q.empty()) { int u = q.front(); q.pop(); for (auto v: g[u]) { if (!visited[v]) { visited[v] = true; q.push(v); val[v] = val[u] + 1; } } } } int main(){ scanf("%d", &n); for (int i = 1; i <= n; i++) { int num; scanf("%d", &num); for (int j = 0; j < num; j++) { int v; scanf("%d", &v); g[v].push_back(i); } } for (int i = 1; i <= n; i++) { memset(visited, 0, sizeof(visited)); val[i] = 1; bool f = true; bfs(i); for (int j = 1; j <= n; j++) { if (!visited[j]) { f = false; break; } } if (!f) continue; int sum = 0; for (int j = 1; j <= n; j++) sum += val[j]; ans = min(ans, sum); } printf("%d", ans); return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
bosses.cpp:28:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int num; scanf("%d", &num);
                  ~~~~~^~~~~~~~~~~~
bosses.cpp:30:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int v; scanf("%d", &v);
                    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...