제출 #1030920

#제출 시각아이디문제언어결과실행 시간메모리
1030920belgianbotBitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms608 KiB
#include <bits/stdc++.h> using namespace std; int N, M, Q; vector<vector<int>> adj; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> N >> M >> Q; adj.resize(N); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; adj[b].push_back(a); } vector<set<pair<int,int>>> sol(N); for (int i = 0; i < N; i++) { vector<int> processed(N, INT_MIN); sol[i].insert({0,i}); for (int j : adj[i]) { sol[i].insert({-1,j}); for (auto x : sol[j]) { if (processed[x.second] < x.first) continue; processed[x.second] = x.first - 1; sol[i].insert({x.first - 1, x.second}); } } } while (Q--) { int T, Y; cin >> T >> Y; T--; vector<int> busy(Y); for (int i = 0; i < Y; i++) { cin >> busy[i]; busy[i]--; } bool ok = false; for (auto i : sol[T]) { auto it = lower_bound(busy.begin(), busy.end(), i.second); if (it == busy.end() || (*it) != i.second) { ok = true; cout << -i.first << '\n'; break; } } if (!ok) cout << -1 << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...