Submission #860655

#TimeUsernameProblemLanguageResultExecution timeMemory
860655clamsBitaro’s Party (JOI18_bitaro)C++17
0 / 100
2 ms5724 KiB
#include <bits/stdc++.h> using namespace std; template <typename T> bool mini(T& a, T b) { if (b < a) return a = b, true; return false; } template <typename T> bool maxi(T& a, T b) { if (b > a) return a = b, true; return false; } const int N = 1e5 + 5; const int M = 2e5 + 5; const int Q = 1e5 + 5; int n, m, q; vector<int> adj[N], radj[N]; int t, y; int c[N]; int f[N]; bool ded[N]; void solve() { cin >> t >> y; for (int i = 1; i <= y; i++) { cin >> c[i]; ded[c[i]] = 1; } memset(f, -1, sizeof f); int ans = -1; for (int i = t; i >= 1; i--) { if (!ded[i]) maxi(ans, f[i]); for (int v : radj[i]) { maxi(f[v], f[i] + 1); } } cout << ans; } signed main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m >> q; for (int i = 1; i <= m; i++) { int s, e; cin >> s >> e; adj[s].push_back(e); radj[e].push_back(s); } assert(q == 1); while (q--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...