Submission #752480

#TimeUsernameProblemLanguageResultExecution timeMemory
752480bachhoangxuan사이버랜드 (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define pdi pair<double,pii> #define fi first #define se second double solve(int N, int M, int K, int T, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { K=min(K,100); vector<vector<double>> dist(N,vector<double>(K+1,1e14)); vector<vector<pii>> edge(N); for(int i=0;i<M;i++){ edge[x[i]].push_back({y[i],c[i]}); edge[y[i]].push_back({x[i],c[i]}); } priority_queue<pdi,vector<pdi>,greater<pdi>> pq; dist[0][0]=0;pq.push({0,{0,0}}); bool ok=false; int res=1e14; while(!pq.empty()){ auto [d,x]=pq.top();pq.pop(); int u=x.fi,k=x.se; if(u==T){ res=min(res,d); ok=true;continue; } for(auto [v,w]:edge[u]){ double nd=dist[u][k]*(arr[u]?1.0/arr[u]:0)+w; int nk=k+(arr[u]==2); if(nk<=k && dist[v][nk]>nd){ dist[v][nk]=nd; pq.push({nd,{v,nk}}); } if(dist[u][k]+w<dist[v][k]){ dist[v][k]=dist[u][k]+w; pq.push({dist[u][k]+w,{v,k}}); } } } if(ok) return res; else return -1; }

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:20:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+14' to '2147483647' [-Woverflow]
   20 |     int res=1e14;
      |             ^~~~
cyberland.cpp:25:26: error: no matching function for call to 'min(int&, std::tuple_element<0, std::pair<double, std::pair<int, int> > >::type&)'
   25 |             res=min(res,d);
      |                          ^
In file included from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
cyberland.cpp:25:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::tuple_element<0, std::pair<double, std::pair<int, int> > >::type' {aka 'double'})
   25 |             res=min(res,d);
      |                          ^
In file included from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
cyberland.cpp:25:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::tuple_element<0, std::pair<double, std::pair<int, int> > >::type' {aka 'double'})
   25 |             res=min(res,d);
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
cyberland.cpp:25:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |             res=min(res,d);
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
cyberland.cpp:25:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |             res=min(res,d);
      |                          ^