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>
#define ll long long
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define endl '\n'
#define pb push_back
using namespace std ;
//fflush(stdout) ;
const int Max_n=1e5+10 ;
vector<int>v[Max_n] ;
set<int>s ;
int ans=0 ;
void dfs(int x , int r){
if(s.count(x)==0) ans=max(ans,r) ;
for(int i:v[x]){
dfs(i,r+1) ;
}
}
int main(){
int n , m , q ; cin >> n >> m >> q ;
for(int i=0 ; i<m ; i++){
int a , e ; cin >> a >> e ;
v[max(a,e)].pb(min(a,e)) ;
}
while(q--){
int t , y ; cin >> t >> y ;
s.clear() ;
for(int i=0 ; i<y ; i++){
int a ; cin >> a ;
s.insert(a) ;
}
ans=-1 ;
dfs(t , 0) ;
cout << ans << endl ;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |