제출 #567362

#제출 시각아이디문제언어결과실행 시간메모리
567362RealSnakeBitaro’s Party (JOI18_bitaro)C++14
0 / 100
3 ms4948 KiB
#include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<pair<int, int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define mod 1000000007 ofstream fout(".out"); ifstream fin(".in"); vector<int> node[100001], depth[100001]; int d[100001]; bool b[100001]; signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, q; cin >> n >> m >> q; for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; node[v].push_back(u); } if(q == 1) { for(int i = 1; i <= n; i++) d[i] = 1e9; int t, sz; cin >> t >> sz; for(int i = 0; i < sz; i++) { int x; cin >> x; b[x] = 1; } set<pair<int, int>> s; s.insert({0, t}); d[t] = 0; while(s.size()) { pair<int, int> p = *s.begin(); s.erase(s.begin()); int x = p.second; int cost = p.first; if(cost > d[x]) continue; depth[d[x]].push_back(x); for(int i : node[x]) { if(cost + 1 < d[i]) { d[i] = cost + 1; s.insert({cost + 1, i}); } } } int ans = -1; for(int i = n; i > 0; i--) { for(int j : depth[i]) { if(!b[j]) { ans = max(ans, i); break; } } } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...