제출 #566972

#제출 시각아이디문제언어결과실행 시간메모리
5669721zaid1Bitaro’s Party (JOI18_bitaro)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long typedef long long ll; const int M = 3e3 + 5, MOD = 1e9+7; vector<int> node[M]; int dist[M][M]; void bfs(int s) { priority_queue<pair<int, int>> q; q.push({0, s}); while (!q.empty()) { auto [d, t] = q.top();q.pop(); if (d < dist[s][t]) continue; for (int i:node[t]) { if (d+1 >= dist[s][i]) { dist[s][i] = d + 1; q.push({dist[s][i], i}); } } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); srand(time(0)); int n, m, t; cin >> n >> m >> t; for (int i = 1; i <= m; i++) { int a, b; cin >> a >> b; node[b].push_back(a); } if (t == 1) { } else { for (int i = 1; i <= n; i++) bfs(i); while (t--) { int s, y; cin >> s >> y; int ans = -1; set<int> st; for (int i = 1; i <= n; i++) st.insert(i); for (int i = 1; i <= y; i++) { int a; cin >> a; st.erase(a); } for (int i = 1; i <= n; i++) { ans = max(ans, (dist[s][i]?dist[s][i]:-1)); } cout << ans << endl; } } return 0; } /* 12 17 10 1 2 2 3 3 4 1 5 2 6 3 7 4 8 5 6 6 7 7 8 5 9 6 10 7 11 8 12 9 10 10 11 11 12 6 3 1 7 12 3 7 1 2 3 4 5 6 7 11 3 1 3 5 9 2 1 9 8 4 1 2 3 4 1 1 1 12 0 10 3 1 6 10 11 8 2 3 5 6 7 9 10 11 8 7 2 3 4 5 6 7 8 */

컴파일 시 표준 에러 (stderr) 메시지

bitaro.cpp: In function 'void bfs(long long int)':
bitaro.cpp:14:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   14 |         auto [d, t] = q.top();q.pop();
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...