제출 #530987

#제출 시각아이디문제언어결과실행 시간메모리
530987mat50013Crocodile's Underground City (IOI11_crocodile)C++11
컴파일 에러
0 ms0 KiB
#include "crocodile.h" using namespace std; using ll = long long; vector<pair<int, int> > G[MAX_N + 5]; ll dist[MAX_N + 5]; bool waiting[MAX_N + 5], viz[MAX_N + 5]; bool cmp(pair<int, int> a, pair<int, int> b) { return (dist[a.first] + a.second) < (dist[b.first] + b.second); } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { 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]}); for(int i = 0; i < N; ++i) dist[i] = LLONG_MAX / 2; queue<int> q; for(int i = 0; i < K; ++i) { dist[P[i]] = 0; q.push(P[i]); } while(!q.empty()) { int nd = q.front(); q.pop(); waiting[nd] = 0; for(auto it: G[nd]) if(dist[nd] + it.second < dist[it.first]) { dist[it.first] = dist[nd] + it.second; if(!waiting[it.first]) { q.push(it.first); waiting[it.first] = 1; } } } int timp = 0, curNd = 0; viz[curNd] = 1; while(dist[curNd] != 0) { sort(G[curNd].begin(), G[curNd].end(), cmp); for(int i = 1; i < (G[curNd].size()); ++i) if(!viz[G[curNd][i].first]) { timp += G[curNd][i].second; curNd = G[curNd][i].first; viz[curNd] = 1; break; } } return timp; }

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

crocodile.cpp:5:1: error: 'vector' does not name a type
    5 | vector<pair<int, int> > G[MAX_N + 5];
      | ^~~~~~
crocodile.cpp:6:9: error: 'MAX_N' was not declared in this scope
    6 | ll dist[MAX_N + 5];
      |         ^~~~~
crocodile.cpp:7:14: error: 'MAX_N' was not declared in this scope
    7 | bool waiting[MAX_N + 5], viz[MAX_N + 5];
      |              ^~~~~
crocodile.cpp:7:30: error: 'MAX_N' was not declared in this scope
    7 | bool waiting[MAX_N + 5], viz[MAX_N + 5];
      |                              ^~~~~
crocodile.cpp:8:10: error: 'pair' was not declared in this scope
    8 | bool cmp(pair<int, int> a, pair<int, int> b)
      |          ^~~~
crocodile.cpp:2:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
    1 | #include "crocodile.h"
  +++ |+#include <utility>
    2 | 
crocodile.cpp:8:15: error: expected primary-expression before 'int'
    8 | bool cmp(pair<int, int> a, pair<int, int> b)
      |               ^~~
crocodile.cpp:8:20: error: expected primary-expression before 'int'
    8 | bool cmp(pair<int, int> a, pair<int, int> b)
      |                    ^~~
crocodile.cpp:8:28: error: 'pair' was not declared in this scope
    8 | bool cmp(pair<int, int> a, pair<int, int> b)
      |                            ^~~~
crocodile.cpp:8:28: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
crocodile.cpp:8:33: error: expected primary-expression before 'int'
    8 | bool cmp(pair<int, int> a, pair<int, int> b)
      |                                 ^~~
crocodile.cpp:8:38: error: expected primary-expression before 'int'
    8 | bool cmp(pair<int, int> a, pair<int, int> b)
      |                                      ^~~
crocodile.cpp:8:44: error: expression list treated as compound expression in initializer [-fpermissive]
    8 | bool cmp(pair<int, int> a, pair<int, int> b)
      |                                            ^
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:15:9: error: 'G' was not declared in this scope
   15 |         G[R[i][0]].push_back({R[i][1], L[i]}), G[R[i][1]].push_back({R[i][0], L[i]});
      |         ^
crocodile.cpp:17:9: error: 'dist' was not declared in this scope
   17 |         dist[i] = LLONG_MAX / 2;
      |         ^~~~
crocodile.cpp:17:19: error: 'LLONG_MAX' was not declared in this scope
   17 |         dist[i] = LLONG_MAX / 2;
      |                   ^~~~~~~~~
crocodile.cpp:2:1: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    1 | #include "crocodile.h"
  +++ |+#include <climits>
    2 | 
crocodile.cpp:18:5: error: 'queue' was not declared in this scope
   18 |     queue<int> q;
      |     ^~~~~
crocodile.cpp:2:1: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    1 | #include "crocodile.h"
  +++ |+#include <queue>
    2 | 
crocodile.cpp:18:11: error: expected primary-expression before 'int'
   18 |     queue<int> q;
      |           ^~~
crocodile.cpp:21:9: error: 'dist' was not declared in this scope
   21 |         dist[P[i]] = 0;
      |         ^~~~
crocodile.cpp:22:9: error: 'q' was not declared in this scope
   22 |         q.push(P[i]);
      |         ^
crocodile.cpp:24:12: error: 'q' was not declared in this scope
   24 |     while(!q.empty())
      |            ^
crocodile.cpp:28:9: error: 'waiting' was not declared in this scope
   28 |         waiting[nd] = 0;
      |         ^~~~~~~
crocodile.cpp:29:22: error: 'G' was not declared in this scope
   29 |         for(auto it: G[nd])
      |                      ^
crocodile.cpp:30:16: error: 'dist' was not declared in this scope
   30 |             if(dist[nd] + it.second < dist[it.first])
      |                ^~~~
crocodile.cpp:41:5: error: 'viz' was not declared in this scope
   41 |     viz[curNd] = 1;
      |     ^~~
crocodile.cpp:42:11: error: 'dist' was not declared in this scope
   42 |     while(dist[curNd] != 0)
      |           ^~~~
crocodile.cpp:44:14: error: 'G' was not declared in this scope
   44 |         sort(G[curNd].begin(), G[curNd].end(), cmp);
      |              ^
crocodile.cpp:44:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   44 |         sort(G[curNd].begin(), G[curNd].end(), cmp);
      |         ^~~~
      |         short