QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#116587#6559. A Tree and Two EdgesNYCU_Yamada#Compile Error//C++141.5kb2023-06-29 15:59:472023-06-29 15:59:48

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-29 15:59:48]
  • 评测
  • [2023-06-29 15:59:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int int64_t

const int maxn = 2e5 + 87;

int f[maxn] = {}, dis[maxn] = {};
vector<pair<int, int>> G[maxn];
int n, m, k;
    

void solve() {
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i) {
        cin >> f[i];
    }
    for(int i = 1; i <= n; ++i) {
        f[i] += f[i - 1];
    }
    for(int i = 1; i <= n; ++i) {
        G[i].emplace_back(i - 1, f[i] - f[i - 1]); // s[i] - s[i - 1] <= f[i]
        G[i - 1].emplace_back(i, 0); // s[i] - s[i - 1] >= 0
    }
    for(int i = 1; i <= n; ++i) {
        int p = max(i - m, 0LL);
        int d = min(k, f[i] - f[p]);
        G[p].emplace_back(i, -d); // s[i] - s[p] >= d
    }
    for(int i = 1; i < m; ++i) {
        int p = max(n - m + i, 0LL);
        int d = min(k, f[n] - f[p]);
        G[p].emplace_back(n, -d);  // s[n] - s[p] >= d
    }
    // min distance
    priority_queue<pair<int, int>> pq;
    memset(dis, 0x3f, sizeof(dis));
    dis[0] = 0;
    pq.emplace(dis[0], 0);
    while(pq.size()) {
        int x = pq.top().second;
        int d = -pq.top().first;
        pq.pop();
        if(dis[x] != d) continue;
        for(auto e : G[x]) {
            if(dis[e.first] > dis[x] + e.second) {
                dis[e.first] = dis[x] + e.second;
                pq.emplace(-dis[e.first], e.first);
            }
        }
    }
    cout << -dis[n] << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    solve();
    
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:26:20: error: no matching function for call to ‘max(int64_t, long long int)’
   26 |         int p = max(i - m, 0LL);
      |                 ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 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 answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:26:20: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   26 |         int p = max(i - m, 0LL);
      |                 ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 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 answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:26:20: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   26 |         int p = max(i - m, 0LL);
      |                 ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:26:20: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   26 |         int p = max(i - m, 0LL);
      |                 ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:26:20: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   26 |         int p = max(i - m, 0LL);
      |                 ~~~^~~~~~~~~~~~
answer.code:31:20: error: no matching function for call to ‘max(int64_t, long long int)’
   31 |         int p = max(n - m + i, 0LL);
      |                 ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 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 answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:31:20: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   31 |         int p = max(n - m + i, 0LL);
      |                 ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 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,
 ...