제출 #426469

#제출 시각아이디문제언어결과실행 시간메모리
426469tengiz05Bitaro’s Party (JOI18_bitaro)C++17
7 / 100
2081 ms10284 KiB
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m, q; std::cin >> n >> m >> q; std::vector<std::vector<int>> e(n); for (int i = 0; i < m; i++) { int u, v; std::cin >> u >> v; u--; v--; e[v].push_back(u); } while (q--) { int t, k; std::cin >> t >> k; t--; std::vector<int> bad(n); for (int i = 0, x; i < k; i++) { std::cin >> x; bad[--x] = true; } std::priority_queue<std::pair<int, int>> q; std::vector<int> dist(n, -1); dist[t] = 0; q.emplace(0, t); while (!q.empty()) { auto [d, u] = q.top(); q.pop(); if (d < dist[u]) { continue; } for (auto v : e[u]) { if (dist[v] < d + 1) { dist[v] = d + 1; q.emplace(dist[v], v); } } } int ans = -1; for (int i = 0; i < n; i++) { if (!bad[i]) { ans = std::max(ans, dist[i]); } } std::cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...