Submission #1253919

#TimeUsernameProblemLanguageResultExecution timeMemory
1253919anfi사이버랜드 (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second const double inf = 1e18; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){ double ans = 1e18; K = min(K, 100); vector<pair<int,int>> adj[N]; vector<int> dp(N, inf), tmp(N, inf) for(int i = 0;i < M; i++){ adj[x[i]].push_back({y[i], c[i]}); adj[y[i]].push_back({x[i], c[i]}); } priority_queue<pair<double, int>> pq; tmp[0] = 0.0; for(int i = 0; i < N; i++){ if(arr[i] == 0) dp[i][0] = 0.0; } while(!pq.empty()){ auto [c, u] = pq.top(); pq.pop(); if(c > dp[u]) continue; for(auto &[v, w] : adj[u]){ double cost = c+w; if(dp[v][pos] > cost){ dp[v][pos] = cost; pq.push({dp[v][pos], v, pos}); } if(a[u] == 2 && pos < K){ double co = (c+w)/2.0; if(dp[v][pos+1] > co){ dp[v][pos+1] = co; pq.push({co, v, pos+1}); } } } } for(int i = 0; i <= K; i++) ans = min(ans, dp[H][i]); return (ans >= inf/2 ? -1.0 : ans); }

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:11:23: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   11 |     vector<int> dp(N, inf), tmp(N, inf)
      |                       ^~~
cyberland.cpp:11:36: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   11 |     vector<int> dp(N, inf), tmp(N, inf)
      |                                    ^~~
cyberland.cpp:12:5: error: expected ',' or ';' before 'for'
   12 |     for(int i = 0;i < M; i++){
      |     ^~~
cyberland.cpp:12:19: error: 'i' was not declared in this scope
   12 |     for(int i = 0;i < M; i++){
      |                   ^
cyberland.cpp:19:30: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   19 |         if(arr[i] == 0) dp[i][0] = 0.0;
      |                              ^
cyberland.cpp:26:22: error: 'pos' was not declared in this scope; did you mean 'pow'?
   26 |             if(dp[v][pos] > cost){
      |                      ^~~
      |                      pow
cyberland.cpp:28:24: error: no matching function for call to 'std::priority_queue<std::pair<double, int> >::push(<brace-enclosed initializer list>)'
   28 |                 pq.push({dp[v][pos], v, pos});
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from cyberland.cpp:1:
/usr/include/c++/11/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++/11/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++/11/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++/11/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)
      |            ~~~~~~~~~~~~~^~~
cyberland.cpp:30:16: error: 'a' was not declared in this scope
   30 |             if(a[u] == 2 && pos < K){
      |                ^
cyberland.cpp:30:29: error: 'pos' was not declared in this scope; did you mean 'pow'?
   30 |             if(a[u] == 2 && pos < K){
      |                             ^~~
      |                             pow
cyberland.cpp:34:28: error: no matching function for call to 'std::priority_queue<std::pair<double, int> >::push(<brace-enclosed initializer list>)'
   34 |                     pq.push({co, v, pos+1});
      |                     ~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from cyberland.cpp:1:
/usr/include/c++/11/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++/11/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++/11/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++/11/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)
      |            ~~~~~~~~~~~~~^~~
cyberland.cpp:39:53: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   39 |     for(int i = 0; i <= K; i++) ans = min(ans, dp[H][i]);
      |                                                     ^