제출 #30721

#제출 시각아이디문제언어결과실행 시간메모리
30721RayaBurong25_1Bosses (BOI16_bosses)C++14
100 / 100
723 ms2224 KiB
#include <stdio.h> #include <vector> #include <queue> #define INF 1000000000 std::vector<int> AdjList[5005]; int min(int a, int b) { return (a < b)?a:b; } int Vis[5005]; int cnt, sz; int sum; std::queue<int> Q; int H[5005]; int N; void BFS(int u) { // printf("DFS %d %d\n", u, pa); int i; for (i = 1; i <= N; i++) H[i] = INF; Q.push(u); H[u] = 1; sum += H[u]; sz++; int p; int v, s; while (!Q.empty()) { p = Q.front(); Q.pop(); s = AdjList[p].size(); for (i = 0; i < s; i++) { v = AdjList[p][i]; if (H[v] == INF) { Q.push(v); H[v] = H[p] + 1; sum += H[v]; sz++; } } } } int main() { scanf("%d", &N); int i, j, K; int p; for (i = 1; i <= N; i++) { scanf("%d", &K); for (j = 0; j < K; j++) { scanf("%d", &p); AdjList[p].push_back(i); } } int Ans = INF; // int r; for (i = 1; i <= N; i++) { // printf("Root %d\n", i); cnt++; sz = 0; sum = 0; BFS(i); // printf("%lld\n", sum); if (sz == N) Ans = min(Ans, sum); } printf("%d", Ans); }

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

bosses.cpp: In function 'int main()':
bosses.cpp:48:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
bosses.cpp:53:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &K);
                        ^
bosses.cpp:56:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &p);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...