답안 #1090710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090710 2024-09-18T15:40:24 Z trandangquang 날다람쥐 (JOI14_ho_t4) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5+5;

using ll = long long;

int n, m, x, h[N]; ll mxh[N];
vector <pair <int, int>> adj[N];

int main() {
    cin.tie(0)->sync_with_stdio(0);

    cin >> n >> m >> x;
    for(int i = 1; i <= n; ++i) cin >> h[i];
    for(int i = 1; i <= m; ++i) {
        int u, v, w; cin >> u >> v >> w;
        if(h[u] >= w) adj[u].emplace_back(v, w);
        if(h[v] >= w) adj[v].emplace_back(u, w);
    }

    fill(mxh+1, mxh+1+n, -1e18);
    mxh[1] = x;

    priority_queue <pair <ll, int>> pq;
    pq.push({x, 1});

    while(pq.size()) {
        pair <ll, int> tp = pq.top(); pq.pop();
        ll hu = tp.first; int u = tp.second;

        if(hu < mxh[u]) continue;

        for(pair <int, int> i : adj[u]) {
            int v = i.first, w = i.second;
            ll hv = min(hu-w, h[v]);
            if(hv > mxh[v]) {
                mxh[v] = hv;
                pq.push({hv, v});
            }
        }
    }

    if(mxh[n] == (ll)-1e18) cout << "-1\n";
    else cout << x + h[n] - 2*mxh[n] << '\n';
}

Compilation message

2014_ho_t4.cpp: In function 'int main()':
2014_ho_t4.cpp:36:35: error: no matching function for call to 'min(ll, int&)'
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from 2014_ho_t4.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:
2014_ho_t4.cpp:36:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from 2014_ho_t4.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:
2014_ho_t4.cpp:36:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from 2014_ho_t4.cpp:1:
/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:
2014_ho_t4.cpp:36:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from 2014_ho_t4.cpp:1:
/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:
2014_ho_t4.cpp:36:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^