Submission #869558

#TimeUsernameProblemLanguageResultExecution timeMemory
869558AverageAmogusEnjoyerBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2016 ms7052 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> bool cmin(T &i, T j) { return i > j ? i=j,1:0; } template<class T> bool cmax(T &i, T j) { return i < j ? i=j,1:0; } const int N=1e5; int n,m,q,dp[N],rm[N]; bool bad[N]; vector<int> adj[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> q; for (int s,e;m--;) { cin >> s >> e; adj[--s].push_back(--e); } for (int t,f;q--;) { cin >> t >> f; --t; for (int i=0;i<f;i++) { cin >> rm[i]; bad[--rm[i]]=true; } int res=-1; memset(dp,0xc0,4*n); dp[t]=0; if (!bad[t]) { res=0; } for (int i=t-1;i>=0;--i) { for (int &j:adj[i]) { cmax(dp[i],1+dp[j]); } if (!bad[i]) { cmax(res,dp[i]); } } cout << res << "\n"; for (int i=0;i<f;i++) { bad[rm[i]]=false; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...