Submission #656068

#TimeUsernameProblemLanguageResultExecution timeMemory
656068BehradmBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2059 ms10060 KiB
/*\ In The Name Of GOD * Beyrad :D \*/ #include "bits/stdc++.h" #define sz(x) ((int) (x).size()) using namespace std; const int N = 2e5 + 5; vector<int> g[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n, m, q; cin >> n >> m >> q; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; --u, --v; g[u].push_back(v); } while (q--) { int x, t; cin >> x >> t, x--; vector<int> dp(n, -1); dp[x] = 0; for (int i = x - 1; i >= 0; i--) { for (int j : g[i]) { if (dp[j] != -1) dp[i] = max(dp[i], 1 + dp[j]); } } vector<bool> mk(n); for (int i = 0; i < t; i++) { int y; cin >> y, y--, mk[y] = 1; } int ans = -1; for (int i = 0; i < n; i++) if (!mk[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...