제출 #978940

#제출 시각아이디문제언어결과실행 시간메모리
978940Panda50O악어의 지하 도시 (IOI11_crocodile)C++14
컴파일 에러
0 ms0 KiB
#include "crocodile.h" #include<bits/stdc++.h> using namespace std; #define MAX_N 50005 #define MAX_M 1000005 #define pii pair<int,int> const int INF = 2e9+5; // vector<pair<int,int>> adj[MAX_N]; // int N, M, R[MAX_M][2], L[MAX_M], K, P[MAX_N]; int mn_target[MAX_N][2], dist[MAX_N]; bool target[MAX_N], vis[MAX_N]; priority_queue<pii, vector<pii>, greater<pii>> pq; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for(int i = 0; i < N; ++i) { mn_target[i][0] = INF; mn_target[i][1] = INF; dist[i] = INF; } for(int i = 0; i < M; ++i) { int a = R[i][0], b = R[i][1], c = L[i]; adj[a].emplace_back(b, c); adj[a].emplace_back(b, c); } for(int i = 0; i < K; ++i) { target[P[i]] = true; } for(int i = 0; i < M; ++i) { int a = R[i][0], b = R[i][1], c = L[i]; if((target[a] && target[b]) || (!target[a] && !target[b])) continue; if(target[a]) swap(a, b); if(c <= mn_target[a][0]) { mn_target[a][1] = mn_target[a][0]; mn_target[a][0] = c; } else if (c < mn_target[a][1]) { mn_target[a][1] = c; } } pq.emplace(0, 0); dist[0] = 0; while(!pq.empty()) { auto [d, u] = pq.top(); pq.pop(); if(vis[u]) continue; vis[u] = true; for(auto [v, w] : adj[u]) { if(target[v]) continue; if(!vis[v] && dist[v] > dist[u] + w) { dist[v] = dist[u] + w; pq.emplace(dist[v], v); } } } int ans = INF; for(int i = 0; i < N; ++i) { if(target[i]) continue; ans = min(ans, dist[i] + mn_target[i][1]); } return ans; } // int main() { // ios_base::sync_with_stdio(0); cin.tie(0); // int ans; // cin >> N >> M >> K; // for(int i = 0; i < M; ++i) // cin >> R[i][0] >> R[i][1] >> L[i]; // for(int i = 0; i < K; ++i) // cin >> P[i]; // ans = travel_plan(N,M,R,L,K,P); // cout << ans; // }

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

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:25:5: error: 'adj' was not declared in this scope
   25 |     adj[a].emplace_back(b, c);
      |     ^~~
crocodile.cpp:47:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |     auto [d, u] = pq.top();
      |          ^
crocodile.cpp:51:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   51 |     for(auto [v, w] : adj[u]) {
      |              ^
crocodile.cpp:51:23: error: 'adj' was not declared in this scope
   51 |     for(auto [v, w] : adj[u]) {
      |                       ^~~