제출 #1265753

#제출 시각아이디문제언어결과실행 시간메모리
1265753canhnam357Bitaro’s Party (JOI18_bitaro)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, q; cin >> n >> m >> q; vector<pair<int, int>> e(m); for (auto &[u, v] : e) cin >> v >> u; sort(e.rbegin(), e.rend()); while (q--) { int t; cin >> t; int k; cin >> k; vector<int> c(k); for (int &i : c) cin >> i; vector<int> dp(n + 1, -1); dp[t] = 0; for (auto [u, v] : e) { if (dp[u] >= 0) { dp[v] = max(dp[v], dp[u] + 1); } } int ans = -1, j = 0; for (int i = 1; i <= n; i++) { if (dp[i] >= 0) { if (j < k && c[j] == i) j++; else { 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...