제출 #853912

#제출 시각아이디문제언어결과실행 시간메모리
853912overwatch9Bitaro’s Party (JOI18_bitaro)C++17
14 / 100
2035 ms12356 KiB
#include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; const int maxn = 1e5 + 1; vector <int> adj[maxn], adjr[maxn]; bool blocked[maxn]; int main() { ios_base::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 a, b; cin >> a >> b; adj[a].push_back(b); adjr[b].push_back(a); } while (q--) { int t, y; cin >> t >> y; fill(blocked, blocked + n + 1, false); for (int i = 0; i < y; i++) { int x; cin >> x; blocked[x] = true; } vector <int> dp(n+1, -1); for (int i = 1; i <= n; i++) { if (!blocked[i]) dp[i] = 0; for (auto j : adjr[i]) { if (dp[j] != -1) dp[i] = max(dp[i], dp[j] + 1); } } cout << dp[t] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...