제출 #197121

#제출 시각아이디문제언어결과실행 시간메모리
197121dantoh000Bosses (BOI16_bosses)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> adjlist[5005];
int d[5005];
queue<int> q;
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 1; i <= n; i++){
        int k;
        scanf("%d",&k);
        while (k--){
            int x;
            scanf("%d",&x);
            adjlist[x].push_back(i);
        }
    }
    int ans = 1000000000;
    for (int i = 1; i <= n; i++){
        memset(d,-1,sizeof(d));
        d[i] = 0;
        q.push(i);
        while (q.size()){
            int u = q.front(); q.pop();
            for (auto v : adjlist[u]){
                if (d[v] == -1){
                    d[v] = d[u]+1;
                    q.push(v);
                }
            }
        }
        int sum = 0;
        for (int i = 1; i <= n; i++){
            //printf("%d ",d[i]);
            sum += d[i]+1;
        }
        printf("\n");
        ans = min(ans,sum);
    }
    printf("%d",ans);
}

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

bosses.cpp: In function 'int main()':
bosses.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bosses.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
bosses.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&x);
             ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...