제출 #778788

#제출 시각아이디문제언어결과실행 시간메모리
778788MilosMilutinovic사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") const double eps = 1e-7; const int MAX = 100005; vector<pair<int, int>> g[MAX]; double dist[MAX * 68]; double lst[MAX * 68]; double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> a) { k = min(k, 66); for (int i = 0; i < n; i++) { g[i].clear(); } for (int i = 0; i < m; i++) { g[x[i]].emplace_back(y[i], c[i]); g[y[i]].emplace_back(x[i], c[i]); } vector<int> que(1, 0); vector<bool> was(n, false); was[0] = true; for (int b = 0; b < (int) que.size(); b++) { int i = que[b]; for (auto& p : g[i]) { int j = p.first; if (j == h) { was[j] = true; } if (!was[j]) { was[j] = true; que.push_back(j); } } } if (!was[h]) { return -1; } const double inf = 1e15; k += 1; que.push_back(h); for (int i : que) { for (int j = 0; j < k; j++) { dist[i * k + j] = inf; lst[i * k + j] = inf; } } priority_queue<pair<int, pair<double, int>>> pq; for (int j : que) { if (j == 0 || a[j] == 0) { dist[j * k] = 0; pq.push({0, dist[j * k], j * k}); } } double ans = inf; while (!pq.empty()) { auto it = pq.top(); int v = it.second.second; pq.pop(); int i = v / k; int j = v % k; if (i == h) { ans = min(ans, dist[v]); if (ans <= eps) { return ans; } continue; } if (lst[v] <= dist[v] + eps) { continue; } lst[v] = dist[v]; for (auto& p : g[i]) { int to = p.first; int w = p.second; if (to == 0 || a[to] == 0) { continue; } if (dist[to * k + j] > dist[v] + w + eps) { int nto = to * k + j; dist[nto] = dist[v] + w; pq.push({j, {-dist[nto], nto}}); } if (a[to] == 2) { if (j + 1 < k && dist[to * k + j + 1] > (dist[v] + w) / 2.000000 + eps) { int nto = to * k + j + 1; dist[nto] = (dist[v] + w) / 2.000000; pq.push({j + 1, {-dist[nto], nto}}); } } } } if (ans == inf) { ans = -1; } return ans; } /* 1 3 2 30 2 1 2 1 1 2 12 2 0 4 4.00000000000 1 4 4 30 3 1 0 2 1 0 1 5 0 2 4 1 3 2 2 3 4 2.00000000000 */

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

cyberland.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("O3")
      | 
cyberland.cpp:8: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    8 | #pragma GCC optimization ("unroll-loops")
      | 
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:58:38: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<double, int> > >::push(<brace-enclosed initializer list>)'
   58 |       pq.push({0, dist[j * k], j * k});
      |                                      ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::pair<double, int> >; _Sequence = std::vector<std::pair<int, std::pair<double, int> >, std::allocator<std::pair<int, std::pair<double, int> > > >; _Compare = std::less<std::pair<int, std::pair<double, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<double, int> >]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, std::pair<double, int> >&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, std::pair<double, int> >; _Sequence = std::vector<std::pair<int, std::pair<double, int> >, std::allocator<std::pair<int, std::pair<double, int> > > >; _Compare = std::less<std::pair<int, std::pair<double, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<double, int> >]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, std::pair<double, int> > >::value_type&&' {aka 'std::pair<int, std::pair<double, int> >&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~