# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991772 | simona1230 | Bitaro’s Party (JOI18_bitaro) | C++17 | 1 ms | 3160 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);
}
int n,m,q;
vector<int> v[100001];
void read()
{
cin>>n>>m>>q;
for(int i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
v[x].push_back(y);
}
}
int dp[100001];
int vert,idx,ans;
int used[100001];
void dfs(int i)
{
//cout<<i<<endl;
if(i==vert)
{
ans=0;
dp[i]=0;
return;
}
for(int j=0;j<v[i].size();j++)
{
int nb=v[i][j];
if(vert<nb)continue;
if(dp[nb]==-1)
dfs(nb);
if(dp[nb]!=-1)
dp[i]=max(dp[i],dp[nb]+1);
}
if(used[i]!=idx)
ans=max(ans,dp[i]);
}
void solve()
{
for(int i=1;i<=q;i++)
{
for(int j=1;j<=n;j++)
dp[j]=-1;
idx=i;
int k,b;
cin>>vert>>k;
for(int j=1;j<=k;j++)
{
cin>>b;
used[b]=i;
}
ans=-1;
dfs(1);
cout<<ans<<endl;
}
}
int main()
{
speed();
read();
solve();
return 0;
}
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... |