제출 #42388

#제출 시각아이디문제언어결과실행 시간메모리
42388HassoonyBosses (BOI16_bosses)C++11
100 / 100
686 ms1132 KiB
#include<bits/stdc++.h>
#include<unordered_map>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double D;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=5002;
int n,k,x;
bool vis[MX];
int val[MX];
vector<int>v[MX],v1[MX];
int ans,mn=1e9;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&k);
        while(k--){
            scanf("%d",&x);
            v[x].push_back(i);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)vis[j]=0,val[j]=0;
        queue<int>q;
        q.push(i);
        val[i]=vis[i]=1;
        while(!q.empty()){
            int x=q.front();q.pop();
            for(auto pp:v[x]){
                if(!vis[pp]){
                    vis[pp]=1;
                    q.push(pp);
                    val[pp]=val[x]+1;
                }
            }
        }
        ans=0;
        for(int j=1;j<=n;j++)ans+=val[j];
        bool b=1;
        for(int j=1;j<=n;j++)if(!vis[j])b=0;
        if(b)mn=min(mn,ans);
    }
    printf("%d\n",mn);
}

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

bosses.cpp: In function 'int main()':
bosses.cpp:17:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
bosses.cpp:19:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
                       ^
bosses.cpp:21:27: 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...