제출 #1191280

#제출 시각아이디문제언어결과실행 시간메모리
1191280justCyberland (APIO23_cyberland)C++20
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define vec vector #define all(x) (x).begin(), (x).end() double solve(int N, int M, int K, int H, vector<int> X, vector<int> Y, vector<int> C, vector<int> S) { const double INF = numeric_limits<double>::max(); map<pair<int, int>, double> edges; vector<vector<pair<int, double>>> adj(N); for (int i = 0; i < M; i++) { int u = X[i], v = Y[i]; double cost = static_cast<double>(C[i]); adj[u].push_back({v, cost}); adj[v].push_back({u, cost}); edges[{u, v}] = cost; edges[{v, u}] = cost; } vector<double> dist(N, INF); dist[0] = 0; priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq; pq.push({0, 0}); while (!pq.empty()) { auto [d, u] = pq.top(); pq.pop(); if (d > dist[u]) continue; for (auto [v, cost] : adj[u]) { if (dist[v] > d + cost) { dist[v] = d + cost; pq.push({dist[v], v}); } } } if (dist[H] == INF) return -1; if (N == 2) { return dist[H]; } // Subtask O1 if (N == 3) { int other = (H == 1 ? 2 : 1); double result = INF; if (edges.count({0, H})) { result = edges[{0, H}]; } if (edges.count({0, other}) && edges.count({other, H})) { if (S[other] == 0) result = min(result, edges[{other, H}]); if (S[other] == 1) result = min(result, dist[H]); if (S[other] == 2) result = min(result, edges[{0, other}] / 2.0 + edges[{other, H}]); } return result; } vector<double> backdist(N, INF); backdist[H] = 0; priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> backpq; backpq.push({0, H}); while (!backpq.empty()) { auto [d, u] = backpq.top(); backpq.pop(); if (d > backdist[u]) continue; for (auto [v, cost] : adj[u]) { if (backdist[v] > d + cost) { backdist[v] = d + cost; backpq.push({backdist[v], v}); } } } if (backdist[0] == INF) return -1; int cost = backdist[0]; for(int i = 0; i < N; i++) { if (S[i] == 0) { cost = min(cost, backdist[i]); } } return cost; } // signed main() { // cout << solve(3, 2, 30, 2, {1, 2}, {2, 0}, {12, 4}, {1, 2, 1}); // }

컴파일 시 표준 에러 (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:82:23: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type&)'
   82 |             cost = min(cost, backdist[i]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from cyberland.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
cyberland.cpp:82:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   82 |             cost = min(cost, backdist[i]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from cyberland.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
cyberland.cpp:82:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   82 |             cost = min(cost, backdist[i]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from cyberland.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
cyberland.cpp:82:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |             cost = min(cost, backdist[i]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from cyberland.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
cyberland.cpp:82:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |             cost = min(cost, backdist[i]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~