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;
#define pb push_back
int n,m,t,u_i,v_i,num,ban[100005],root=sqrt(100000),dp[100005];
int hsh[100005],party;
vector<int> from[100005];
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
root=-1;
cin >> n >> m >> t;
for(int i=1;i<=m;i++)
{
cin >> u_i >> v_i;
from[v_i].pb(u_i);
}
while(t--)
{
cin >> party >> num;
for(int i=1;i<=num;i++)
{
cin >> ban[i];
hsh[ban[i]]=1;
}
/*for(int i=1;i<=n;i++)
{
printf("%d ",hsh[i]);
}
printf("\n");*/
if(num>root)
{
for(int i=1;i<=n;i++)
{
dp[i]=-1e9;
if(hsh[i]==0)dp[i]=0;
for(auto node:from[i])
{
dp[i]=max(dp[i],dp[node]+1);
}
}
if(dp[party]<0)
{
printf("-1\n");
}else
{
printf("%d\n",dp[party]);
}
}else
{
}
for(int i=1;i<=num;i++)
{
hsh[ban[i]]=0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |