제출 #1326146

#제출 시각아이디문제언어결과실행 시간메모리
1326146riafhasan2010악어의 지하 도시 (IOI11_crocodile)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int travel_plan(int n, int m, int R[][2], int L[], int K, int P[]) { vector<pair<int, int>> g[n]; for (int i = 0; i < m; i++) { g[R[i][0]].push_back({R[i][1], L[i]}); g[R[i][1]].push_back({R[i][0], L[i]}); } vector<vector<ll>> cost(n); vector<int> vis(n, 0); queue<int> q; for (int j = 0; j < k; j++) { int i = p[j]; if (g[i].size() == 1) { vis[i] = 1; cost[i].resize(2, 0); q.push(i); } } while (!q.empty()) { auto u = q.front(); q.pop(); sort(cost[u].begin(), cost[u].end()); for (auto [v, w] : g[u]) { vis[v]++; cost[v].push_back(cost[u][1] + w); if(v and vis[v] == g[v].size() - 1) q.push(v); } } return cost[0][1]; }

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

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:14:23: error: 'k' was not declared in this scope
   14 |   for (int j = 0; j < k; j++) {
      |                       ^
crocodile.cpp:15:13: error: 'p' was not declared in this scope
   15 |     int i = p[j];
      |             ^