Submission #992195

#TimeUsernameProblemLanguageResultExecution timeMemory
992195vivkostovBitaro’s Party (JOI18_bitaro)C++14
0 / 100
5 ms10072 KiB
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n,m,qu,a,b,x,y,used[200005],br[200005];
vector<int>v[200005],c;
void bfs(int beg)
{
    used[beg]=1;
    int w,nb;
    queue<int>q;
    q.push(beg);
    //cout<<beg<<endl;
    while(!q.empty())
    {
        w=q.front();
        q.pop();
        if(br[w])br[w]--;
        if(br[w])continue;
        //cout<<w<<" "<<beg<<endl;
        for(int i=0; i<(int)(v[w].size()); i++)
        {
            nb=v[w][i];
            q.push(nb);
            used[nb]=used[w]+1;
            br[nb]++;
        }
    }
}
void read()
{
    cin>>n>>m>>qu;
    for(int i=1; i<=m; i++)
    {
        cin>>a>>b;
        v[b].push_back(a);
    }
    cin>>x>>y;
    for(int j=1; j<=y; j++)
    {
        int h;
        cin>>h;
        c.push_back(h);
    }
    //bfs(x);
    int ma=0,num=0;
    for(int j=1; j<=n; j++)
    {
        //cout<<used[j]<<" "<<j<<endl;
        if(j!=c[num])ma=max(ma,used[j]-1);
        else num++;
        used[j]=0;
        br[j]=0;
    }
    cout<<ma<<endl;
}
int main()
{
    speed();
    read();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...