제출 #341807

#제출 시각아이디문제언어결과실행 시간메모리
341807egod1537Jakarta Skyscrapers (APIO15_skyscraper)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; typedef pair<int, int> pi; #define to first #define cost second #define pos first #define range second struct Q { int pos, cost; }; bool operator<(const Q& a, const Q& b) { return a.cost > b.cost; } vector<pi> V[30001]; int dst[30001]; int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); memset(dst, INF, sizeof(dst)); int n, m; cin >> n >> m; vector<pi> doge(m); vector<int> posdoge(n + 1, -1); int s = 0, e = 0; for (int i = 0; i < m; i++) { cin >> doge[i].pos >> doge[i].range; if (i == 0) s = doge[i].pos; if (i == 1) e = doge[i].pos; } for (int i = 0; i < m; i++) { pi& now = doge[i]; for (int j = now.pos + now.range; j < n; j += now.range) { int dst = j - now.pos; V[now.pos].push_back({ j, dst / now.range }); } for (int j = now.pos - now.range; j >= 0; j -= now.range) { int dst = now.pos - j; V[now.pos].push_back({ j, dst / now.range }); } } priority_queue<Q, vector<Q>, cmp> pq; pq.push({ s, 0 }); while (!pq.empty()) { Q top = pq.top(); pq.pop(); if (top.pos == e) { cout << top.cost; return 0; } for (pi w : V[top.pos]) { if (dst[w.to] > top.cost + w.cost) { dst[w.to] = top.cost + w.cost; pq.push({ w.to, dst[w.to] }); } } } cout << -1; return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:52:31: error: 'cmp' was not declared in this scope; did you mean 'bcmp'?
   52 |  priority_queue<Q, vector<Q>, cmp> pq;
      |                               ^~~
      |                               bcmp
skyscraper.cpp:52:34: error: template argument 3 is invalid
   52 |  priority_queue<Q, vector<Q>, cmp> pq;
      |                                  ^
skyscraper.cpp:53:5: error: request for member 'push' in 'pq', which is of non-class type 'int'
   53 |  pq.push({ s, 0 });
      |     ^~~~
skyscraper.cpp:54:13: error: request for member 'empty' in 'pq', which is of non-class type 'int'
   54 |  while (!pq.empty()) {
      |             ^~~~~
skyscraper.cpp:55:14: error: request for member 'top' in 'pq', which is of non-class type 'int'
   55 |   Q top = pq.top(); pq.pop();
      |              ^~~
skyscraper.cpp:55:24: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   55 |   Q top = pq.top(); pq.pop();
      |                        ^~~
skyscraper.cpp:65:8: error: request for member 'push' in 'pq', which is of non-class type 'int'
   65 |     pq.push({ w.to, dst[w.to] });
      |        ^~~~