제출 #705340

#제출 시각아이디문제언어결과실행 시간메모리
705340ToroTNBosses (BOI16_bosses)C++14
0 / 100
1 ms420 KiB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int n,m,sub,d[5005],u,type,sum,ans=1e9;
vector<int> v[5005];
queue<int> q;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&m);
        for(int j=1;j<=m;j++)
        {
            scanf("%d",&sub);
            v[sub].pb(i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        memset(d,-1,sizeof d);
        d[i]=1;
        q.push(i);
        while(!q.empty())
        {
            u=q.front();
            q.pop();
            for(auto node:v[u])
            {
                if(d[node]==-1)
                {
                    d[node]=d[u]+1;
                    q.push(node);
                }
            }
        }
        sum=0;
        type=0;
        for(int j=1;j<=n;j++)
        {
            if(d[j]==-1)type=-1;
            sum+=d[j];
        }
        if(type==0)
        {
            ans=min(ans,sum);
        }
    }
    printf("%d\n",sum);
}

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

bosses.cpp: In function 'int main()':
bosses.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     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:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf("%d",&sub);
      |             ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...