Submission #567691

#TimeUsernameProblemLanguageResultExecution timeMemory
567691Mount_EverestBitaro’s Party (JOI18_bitaro)C++14
14 / 100
2064 ms13484 KiB
#include<bits/stdc++.h> #define st first #define nd second #define ll long long #define vec vector using namespace std; const int N=1e5+5, mod=1e9+7; int n, m, u, v, e, p, x, t, dis[N], vis[N]; vec<int>g[N]; void dfs(int u){ dis[u]=u==e?0:-2e9; //cout << u << '\n'; if(u^e){ for(auto v : g[u]){ if(!dis[v]){ dfs(v); } dis[u]=max(dis[u],dis[v]); } } ++dis[u]; } int main(){ ios::sync_with_stdio(0),cin.tie(0); cin >> n >> m >> t; for(int i=0; i<m; i++){ cin >> u >> v; g[u].push_back(v); } while(t--){ memset(dis,0,sizeof dis); memset(vis,0,sizeof vis); cin >> e >> p; for(int i=0; i<p; i++){ cin >> x; vis[x]=1; } int ans=-2e9; for(int i=1; i<=n; i++){ if(!vis[i]){ dfs(i); ans=max(ans,dis[i]-1); } } //for(int i=1; i<=n; i++) cout << dis[i] << " "; cout << (ans<0?-1:ans) << '\n'; } } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...