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<iostream>
#include<vector>
#include<queue>
using namespace::std;
vector<int> v[100005];
int ar[100005];
int main(){
int n,m,q;
cin>>n>>m>>q;
for(int i=0,l,r;i<m;i++)
cin>>l>>r,v[r].push_back(l);
while(q--){
int x,k,maxn=0;
cin>>x>>k;
for(int i=0,t;i<k;i++)
cin>>t,ar[t]=1;
queue<pair<int,int>> q;
q.push({x,0});
while(!q.empty()){
int i=q.front().first,w=q.front().second;
q.pop();
if(!ar[i])
maxn=max(maxn,w);
for(auto a:v[i])
q.push({a,w+1});
}
cout<<maxn<<'\n';
for(int i=1;i<=n;i++)
ar[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... |