제출 #531164

#제출 시각아이디문제언어결과실행 시간메모리
5311644fectaBitaro’s Party (JOI18_bitaro)C++17
14 / 100
810 ms479968 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define ld long double #define pii pair<int, int> #define f first #define s second #define boost() cin.tie(0), cin.sync_with_stdio(0) const int MN = 200005, BLK = 100; int n, m, q, u, v, k, dp[MN], s[MN], rem[MN]; vector<int> a[MN], r[MN]; vector<pii> far[MN]; int32_t main() { boost(); cin >> n >> m >> q; for (int i = 1; i <= m; i++) { cin >> u >> v; a[u].push_back(v); r[v].push_back(u); } for (int i = 1; i <= n; i++) { far[i].push_back({0, i}); for (int j : r[i]) for (pii p : far[j]) far[i].push_back({p.f + 1, p.s}); sort(far[i].begin(), far[i].end(), greater<>()); while (far[i].size() > BLK) far[i].pop_back(); } for (int i = 1; i <= q; i++) { cin >> u >> k; for (int j = 1; j <= k; j++) cin >> rem[i], s[rem[i]] = 1; if (k >= BLK) { int ans = -1; for (int j = 1; j <= u; j++) { if (!s[j]) dp[j] = 0; else dp[j] = -0x3f3f3f3f; for (int p : r[j]) dp[j] = max(dp[j], dp[p] + 1); } ans = max(ans, dp[u]); printf("%lld\n", ans); } else { int ans = -1; for (pii p : far[u]) if (!s[p.s]) {ans = p.f; break;} printf("%lld\n", ans); } for (int j = 1; j <= k; j++) s[rem[i]] = 0; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...