제출 #1294091

#제출 시각아이디문제언어결과실행 시간메모리
1294091tunademayoRobot (JOI21_ho_t4)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define pb push_back

const int N = 1e5+5, M = 2e5+5;
vector<array<int, 3>> g[N];
ll di[N], S[M], mn[M];
bool vis[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v, w, c;
        cin >> u >> v >> c >> w;
        g[u].pb({v, w, c});
        g[v].pb({u, w, c});
    }
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> pq;
    fill(di, di+n+1, 1e18);
    di[1] = 0;
    pq.push({0, 1});
    while (!pq.empty()) {
        auto [D, s] = pq.top(); pq.pop();
        if (vis[s]) continue;
        vis[s] = 1;
        for (auto [u, w, c] : g[s]) mn[c] = 1e18, S[c] = 0;
        for (auto [u, w, c] : g[s]) S[c] += w;
        for (auto [u, w, c] : g[s]) mn[c] = min(mn[c], di[u] + S[c]);
        for (auto [u, w, c] : g[s]) {
            if (di[u] > min({di[s] + w, di[s] + S[c] - w, 1e18})) {
                di[u] = min({di[s] + w, di[s] + S[c] - w, 1e18});
                pq.push({di[u], u});
            }
        }
    }
    cout << (di[n] > 1e15 ? -1 : di[n]) << '\n';
}

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

Main.cpp: In function 'int main()':
Main.cpp:34:28: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   34 |             if (di[u] > min({di[s] + w, di[s] + S[c] - w, 1e18})) {
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from Main.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
Main.cpp:34:28: note:   candidate expects 2 arguments, 1 provided
   34 |             if (di[u] > min({di[s] + w, di[s] + S[c] - w, 1e18})) {
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
Main.cpp:34:28: note:   candidate expects 3 arguments, 1 provided
   34 |             if (di[u] > min({di[s] + w, di[s] + S[c] - w, 1e18})) {
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
Main.cpp:34:28: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'double')
   34 |             if (di[u] > min({di[s] + w, di[s] + S[c] - w, 1e18})) {
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
Main.cpp:34:28: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'double')
   34 |             if (di[u] > min({di[s] + w, di[s] + S[c] - w, 1e18})) {
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:35:28: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   35 |                 di[u] = min({di[s] + w, di[s] + S[c] - w, 1e18});
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
Main.cpp:35:28: note:   candidate expects 2 arguments, 1 provided
   35 |                 di[u] = min({di[s] + w, di[s] + S[c] - w, 1e18});
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
Main.cpp:35:28: note:   candidate expects 3 arguments, 1 provided
   35 |                 di[u] = min({di[s] + w, di[s] + S[c] - w, 1e18});
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
Main.cpp:35:28: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'double')
   35 |                 di[u] = min({di[s] + w, di[s] + S[c] - w, 1e18});
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
Main.cpp:35:28: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'double')
   35 |                 di[u] = min({di[s] + w, di[s] + S[c] - w, 1e18});
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~