Submission #992189

#TimeUsernameProblemLanguageResultExecution timeMemory
992189vivkostovBitaro’s Party (JOI18_bitaro)C++14
0 / 100
11 ms25692 KiB
#include<bits/stdc++.h> #define endl "\n" using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n,m,qu,a,b,x[200005],y[200005],used[200005],br[200005]; vector<int>v[200005],c[200005]; void bfs(int beg) { used[beg]=1; int w,nb; queue<int>q; q.push(beg); //cout<<beg<<endl; while(!q.empty()) { w=q.front(); q.pop(); if(br[w])br[w]--; if(br[w])continue; //cout<<w<<" "<<beg<<endl; for(int i=0;i<(int)(v[w].size());i++) { nb=v[w][i]; q.push(nb); used[nb]=used[w]+1; br[nb]++; } } } void read() { cin>>n>>m>>qu; for(int i=1;i<=m;i++) { cin>>a>>b; v[b].push_back(a); } for(int i=1;i<=qu;i++) { cin>>x[i]>>y[i]; for(int j=1;j<=y[i];j++) { int h; cin>>h; c[i].push_back(h); } bfs(x[i]); int ma=0,num=0; for(int j=1;j<=n;j++) { //cout<<used[j]<<" "<<j<<endl; if(j!=c[i][num])ma=max(ma,used[j]-1); else num++; used[j]=0; br[j]=0; } cout<<ma<<endl; } } int main() { speed(); read(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...