Submission #383395

#TimeUsernameProblemLanguageResultExecution timeMemory
383395Leonardo_PaesBitaro’s Party (JOI18_bitaro)C++17
14 / 100
79 ms6636 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; int ans[maxn]; bool chegay[maxn]; vector<int> grafo[maxn]; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n, m, q; cin >> n >> m >> q; for(int i=1; i<=m; i++){ int u, v; cin >> u >> v; grafo[u].push_back(v); } int t, y; cin >> t >> y; vector<bool> mark(n+1, 1); for(int i=0; i<y; i++){ int x; cin >> x; mark[x] = 0; } memset(ans, -1, sizeof ans); ans[t] = 0; chegay[t] = 1; for(int u=t-1; u>=1; u--){ for(int v : grafo[u]){ if(v > t) continue; chegay[u] |= chegay[v]; if(chegay[v]) ans[u] = max(ans[u], ans[v]); } if(chegay[u]) ++ans[u]; } int tfg = -1; for(int i=1; i<=n; i++){ if(mark[i]) tfg = max(tfg, ans[i]); } cout << tfg << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...