Submission #871553

#TimeUsernameProblemLanguageResultExecution timeMemory
871553atomBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2024 ms30032 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); 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); } dp[x] = max(dp[x], -1); cout << dp[x] << "\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...