제출 #717597

#제출 시각아이디문제언어결과실행 시간메모리
717597hafoCrocodile's Underground City (IOI11_crocodile)C++14
컴파일 에러
0 ms0 KiB
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) { ll f[n][2]; int trace[n][2]; priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q; memset(f, 0x3f, sizeof f); memset(trace, -1, sizeof trace); for(int i = 0; i < k; i++) { f[p[i]][0] = 0; q.push({0, p[i]}); } vector<pair<int, int>> g[n]; for(int i = 0; i < m; i++) { int u = r[i][0], v = r[i][1]; g[u].push_back({v, l[i]}); g[v].push_back({u, l[i]}); } while(!q.empty()) { int u = q.top().second; long long fu = q.top().first; q.pop(); if(fu > f[u][1]) continue; for(auto e:g[u]) { int v = e.first, w = e.second; if(f[v][0] == 0) continue; if(trace[u][0] == v || trace[u][1] == v) continue; if(f[v][0] > fu + w) { f[v][1] = f[v][0]; trace[v][1] = trace[v][0]; f[v][0] = fu + w; trace[v][0] = u; q.push({fu + w, v}); } else if(f[v][1] > fu + w) { f[v][1] = fu + w; trace[v][1] = u; q.push({fu + w, v}); } } } int res = 0, u = 0; vector<int> path; while(trace[u][1] != -1) { path.pb(u); u = trace[u][1]; } path.pb(u); for(int i = 0; i < (int) path.size() - 1; i++) { int u = path[i], v = path[i + 1]; for(auto e:g[u]) { if(e.first == v) res += e.second; } } return res; }

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

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:3:5: error: 'll' was not declared in this scope; did you mean 'l'?
    3 |     ll f[n][2];
      |     ^~
      |     l
crocodile.cpp:5:5: error: 'priority_queue' was not declared in this scope
    5 |     priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
      |     ^~~~~~~~~~~~~~
crocodile.cpp:5:20: error: 'pair' was not declared in this scope
    5 |     priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
      |                    ^~~~
crocodile.cpp:5:25: error: expected primary-expression before 'long'
    5 |     priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
      |                         ^~~~
crocodile.cpp:6:12: error: 'f' was not declared in this scope
    6 |     memset(f, 0x3f, sizeof f);
      |            ^
crocodile.cpp:6:5: error: 'memset' was not declared in this scope
    6 |     memset(f, 0x3f, sizeof f);
      |     ^~~~~~
crocodile.cpp:1:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
  +++ |+#include <cstring>
    1 | int travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
crocodile.cpp:10:9: error: 'q' was not declared in this scope
   10 |         q.push({0, p[i]});
      |         ^
crocodile.cpp:12:5: error: 'vector' was not declared in this scope
   12 |     vector<pair<int, int>> g[n];
      |     ^~~~~~
crocodile.cpp:12:17: error: expected primary-expression before 'int'
   12 |     vector<pair<int, int>> g[n];
      |                 ^~~
crocodile.cpp:16:9: error: 'g' was not declared in this scope
   16 |         g[u].push_back({v, l[i]});
      |         ^
crocodile.cpp:20:12: error: 'q' was not declared in this scope
   20 |     while(!q.empty()) {
      |            ^
crocodile.cpp:26:20: error: 'g' was not declared in this scope
   26 |         for(auto e:g[u]) {
      |                    ^
crocodile.cpp:30:31: error: 'w' was not declared in this scope
   30 |             if(f[v][0] > fu + w) {
      |                               ^
crocodile.cpp:45:12: error: expected primary-expression before 'int'
   45 |     vector<int> path;
      |            ^~~
crocodile.cpp:47:9: error: 'path' was not declared in this scope
   47 |         path.pb(u);
      |         ^~~~
crocodile.cpp:50:5: error: 'path' was not declared in this scope
   50 |     path.pb(u);
      |     ^~~~
crocodile.cpp:53:20: error: 'g' was not declared in this scope
   53 |         for(auto e:g[u]) {
      |                    ^
crocodile.cpp:54:27: error: 'v' was not declared in this scope
   54 |             if(e.first == v) res += e.second;
      |                           ^