Submission #567330

#TimeUsernameProblemLanguageResultExecution timeMemory
567330katwamiawBitaro’s Party (JOI18_bitaro)C++14
0 / 100
2075 ms2676 KiB
#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] ;
int c[Max_n] ;
int ans=0 ;

void dfs(int x , int r){
    if(c[x]==0) ans=max(ans,r) ;
    for(int i:v[x]){
        dfs(i,r+1) ;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    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 ;
        for(int i=0 ; i<y ; i++){
            int a ; cin >> a ;
            c[a]=1 ;
        }
        ans=-1 ;
        dfs(t , 0) ;
        cout << ans << endl ;
        //for(int i=1 ; i<=n ; i++) c[i]=0 ;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...