제출 #972629

#제출 시각아이디문제언어결과실행 시간메모리
972629TheSahib사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include "cyberland.h" #include <bits/stdc++.h> #define ll long long #define pii pair<int, int> using namespace std; const ll oo = 1e18; const int MAX = 1e5 + 5; const int MAXK = 70; const int LOGMAX = 10; struct edge{ int u, c; }; int n, k, f; int A[MAX]; vector<edge> g[MAX]; bool visited[MAX]; vector<int> starts; void dfs(int node){ visited[node] = 1; for(auto& e:g[node]){ if(visited[e.u]) continue; dfs(e.u); } } double dist[MAXK + 1][MAX]; priority_queue<pair<double, int>> st; void dijkstra(){ for (int j = 0; j <= k; j++) { for (int i = 0; i < n; i++) { dist[j][i] = oo; } } for(int a:starts){ dist[k][a] = 0; st.push({0, a << LOGMAX + k}); } while(!st.empty()){ double d = -st.top().first; int node = st.top().second >> LOGMAX; int l = st.top().second - (node << LOGMAX); st.pop(); if(dist[l][node] < d) continue; for(auto& e:g[node]){ double b = d + e.c; if(b < dist[l][e.u]){ dist[l][e.u] = b; st.push({-dist[l][e.u], {e.u, l}}); } if(l == 0 || A[e.u] != 2) continue; if(b / 2 < dist[l - 1][e.u]){ dist[l - 1][e.u] = b / 2; st.push({-dist[l - 1][e.u], (e.u << LOGMAX) + (l - 1)}); } } } } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { n = N; k = min(MAXK, K); f = H; starts.clear(); for (int i = 0; i < n; i++) { A[i] = arr[i]; g[i].clear(); visited[i] = 0; } for (int i = 0; i < M; i++) { g[x[i]].push_back({y[i], c[i]}); g[y[i]].push_back({x[i], c[i]}); } g[f].clear(); dfs(0); starts.push_back(0); for (int i = 0; i < n; i++) { if(visited[i] && A[i] == 0){ starts.push_back(i); } } dijkstra(); double ans = oo; for(int i = 0; i <= k; ++i){ ans = min(ans, dist[i][f]); } if(ans == oo){ return -1; } else{ return ans; } }

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

cyberland.cpp: In function 'void dijkstra()':
cyberland.cpp:44:33: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   44 |         st.push({0, a << LOGMAX + k});
      |                          ~~~~~~~^~~
cyberland.cpp:58:50: error: no matching function for call to 'std::priority_queue<std::pair<double, int> >::push(<brace-enclosed initializer list>)'
   58 |                 st.push({-dist[l][e.u], {e.u, l}});
      |                                                  ^
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<double, int>; _Sequence = std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >; _Compare = std::less<std::pair<double, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = 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<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<double, int>; _Sequence = std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >; _Compare = std::less<std::pair<double, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = 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<double, int> >::value_type&&' {aka 'std::pair<double, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~