Submission #560405

#TimeUsernameProblemLanguageResultExecution timeMemory
560405colossal_pepeBitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms384 KiB
#include <iostream> #include <vector> #include <cstring> using namespace std; int n, m, q, t, y; vector<vector<int>> g; void brutus(int u, int dp[]) { if (u > t or dp[u] != -1) return; for (int v : g[u]) { brutus(v, dp); dp[u] = max(dp[u], dp[v] + 1); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> q; g.resize(n); while (m--) { int u, v; cin >> u >> v; u--, v--; g[u].push_back(v); } cin >> t >> y; t--; int dp[n]; memset(dp, -1, sizeof(dp)); dp[t] = 0; for (int i = 0; i < n; i++) { if (dp[i] == -1) brutus(i, dp); } bool absent[n]; memset(absent, 0, sizeof(absent)); for (int i = 0; i < y; i++) { int c; cin >> c; c--; absent[c] = 1; } int ans = -1; for (int i = 0; i < n; i++) { if (not absent[i]) ans = max(ans, dp[i]); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...