Submission #68920

# Submission time Handle Problem Language Result Execution time Memory
68920 2018-08-19T09:09:30 Z Vahan Bosses (BOI16_bosses) C++17
0 / 100
2 ms 996 KB
#include<iostream>
#include<vector>
#include<deque>
#include<cstdio>
using namespace std;
vector<int> g[20000];
deque<int> q;
int n,pp,u[100000],pat=-1;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int a;
        scanf("%d",&a);
        for(int j=1;j<=a;j++)
        {
            int b;
            scanf("%d",&b);
            if(i!=b)
                g[b].push_back(i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        q.push_back(i);
        u[i]=1;
        int t=0;
        while(!q.empty())
        {
            int v=q.front();
            q.pop_front();
            pp+=u[v];
            t++;
            for(int j=0;j<g[v].size();j++)
            {
                int to=g[v][j];
                if(u[to]==0)
                {
                    u[to]=u[v]+1;
                    q.push_back(to);
                }
            }
        }
        if(t==n)
        {
            if(pp<pat || pat==-1)
                pat=pp;
        }
        else
            q.clear();
        for(int j=1;j<=n;j++)
            u[j]=0;
    }
    cout<<pat<<endl;
    return 0;
}

Compilation message

bosses.cpp: In function 'int main()':
bosses.cpp:35:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0;j<g[v].size();j++)
                         ~^~~~~~~~~~~~
bosses.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a);
         ~~~~~^~~~~~~~~
bosses.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&b);
             ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB Output is correct
2 Incorrect 2 ms 996 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB Output is correct
2 Incorrect 2 ms 996 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB Output is correct
2 Incorrect 2 ms 996 KB Output isn't correct
3 Halted 0 ms 0 KB -