Submission #869557

#TimeUsernameProblemLanguageResultExecution timeMemory
869557AverageAmogusEnjoyerBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2037 ms9300 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; dp[t]=0; if (!bad[t]) { res=0; } for (int i=t-1;i>=0;--i) { dp[i]=-(1<<30); for (int &j:adj[i]) { if (j<=t) { 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...