Submission #383384

#TimeUsernameProblemLanguageResultExecution timeMemory
383384Leonardo_PaesBitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 310; int ans[maxn]; vector<int> grafo[maxn]; void dfs(int u, int x){ if(u == x){ ans[u] = 0; return; } for(int v : grafo[u]){ if(ans[v] != -1 or v > x) continue; dfs(v, x); ans[u] = max(ans[u], ans[v]); } ++ans[u]; } 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); dfs(1, t); int tfg = 0; 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...