제출 #871548

#제출 시각아이디문제언어결과실행 시간메모리
871548atomBitaro’s Party (JOI18_bitaro)C++17
0 / 100
6 ms23900 KiB
#include "bits/stdc++.h" // @JASPER'S BOILERPLATE using namespace std; using ll = long long; #define FOR(i, a, b) for(int i = a; i <= b; i++) #define FORD(i, a, b) for(int i = a; i >= b; i--) #define REP(i, b) for(int i = 0; i < b; i++) #define PER(i, b) for(int i = b - 1; i >= 0; i--) #define fi first #define se second #ifdef JASPER #include "debug.h" #else #define debug(...) 166 #endif using pii = pair < int, int >; const int INF = 1e9; const int MOD = 1e9 + 7; const int N = 1e6 + 5; vector <int> adj[N]; int n, m, q; void run_case() { cin >> n >> m >> q; for (int i = 1; i <= m; ++i) { int u, v; cin >> u >> v; adj[v].push_back(u); } while (q--) { int x, c; cin >> x >> c; vector <bool> busy(n + 2, 0); int ans = -1; for (int i = 1; i <= c; ++i) { int y; cin >> y; busy[y] = 1; } vector <int> dp(n + 2, -INF); for (int i = 1; i <= x; ++i) { if (!busy[i]) dp[i] = 0; for (int j : adj[i]) dp[i] = max(dp[i], dp[j] + 1); ans = max(ans, dp[i]); } cout << ans << "\n"; } } signed main() { cin.tie(0) -> sync_with_stdio(0); int Test = 1; //cin >> Test; for (int test = 1; test <= Test; test++){ run_case(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...