Submission #707827

#TimeUsernameProblemLanguageResultExecution timeMemory
707827ToroTNBitaro’s Party (JOI18_bitaro)C++14
0 / 100
2 ms2644 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back int n,m,t,u_i,v_i,num,ban[100005],root=sqrt(100000),dp[100005]; int hsh[100005],party; vector<int> from[100005]; int main() { ios_base::sync_with_stdio(0),cin.tie(0); root=0; cin >> n >> m >> t; for(int i=1;i<=m;i++) { cin >> u_i >> v_i; from[v_i].pb(u_i); } while(t--) { cin >> party >> num; for(int i=1;i<=num;i++) { cin >> ban[i]; hsh[ban[i]]=1; } if(num>root) { for(int i=1;i<=n;i++) { dp[i]=-1e9; if(hsh[i]==0)dp[i]=0; for(auto node:from[i]) { dp[i]=max(dp[i],dp[node]+1); } } if(dp[party]==-1e9) { printf("-1\n"); }else { printf("%d\n",dp[party]); } }else { } for(int i=1;i<=num;i++) { hsh[ban[i]]=0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...