Submission #200838

#TimeUsernameProblemLanguageResultExecution timeMemory
200838ekremBitaro’s Party (JOI18_bitaro)C++98
0 / 100
7 ms2684 KiB
#include<iostream> #include<vector> #include<queue> using namespace::std; vector<int> v[100005]; int ar[100005],maxn,dp[100005]; int DFS(int i){ // cout<<i<<'\n'; for(auto a:v[i]) if(dp[a]==0 && (!ar[a] || v[a].size())){ DFS(a); dp[i]=max(dp[i],(!ar[a] || dp[a]!=0)+dp[a]); } else if((!ar[a] || v[a].size())){ dp[i]=max(dp[i],1+dp[a]); } // cout<<i<<' '<<dp[i]<<'\n'; return dp[i]; } int main(){ ios_base::sync_with_stdio(0); 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; cout<<DFS(x)<<'\n'; for(int i=1;i<=n;i++) ar[i]=0,dp[i]=0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...