# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991795 | simona1230 | Bitaro’s Party (JOI18_bitaro) | C++17 | 39 ms | 10068 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n,m,q;
vector<long long> v[100005];
void read()
{
cin>>n>>m>>q;
for(long long i=1;i<=m;i++)
{
long long x,y;
cin>>x>>y;
v[x].push_back(y);
}
}
long long t,k,b[100005],ans=-1;
long long dp[100005];
void solve()
{
cin>>t>>k;
for(long long i=1;i<=k;i++)
{
long long x;
cin>>x;
b[x]=1;
}
for(long long i=1;i<=n;i++)
dp[i]=-1;
for(long long i=1;i<=n;i++)
{
if(!b[i])dp[i]=max(1LL*0,dp[i]);
for(long long j=0;j<v[i].size();j++)
{
long long nb=v[i][j];
if(dp[i]!=-1)dp[nb]=max(dp[nb],dp[i]+1);
}
//cout<<dp[i]<<endl;
}
cout<<dp[t]<<endl;
}
int main()
{
speed();
read();
solve();
return 0;
}
/*
12 17 10
1 2
2 3
3 4
1 5
2 6
3 7
4 8
5 6
6 7
7 8
5 9
6 10
7 11
8 12
9 10
10 11
11 12
3 7 1 2 3 4 5 6 7
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |