Submission #698512

# Submission time Handle Problem Language Result Execution time Memory
698512 2023-02-13T16:31:40 Z Gital Autobus (COCI22_autobus) C++11
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll dp[75];
vector<pair<ll,ll>> v[75];
bool checked[75];
int n,m;
priority_queue<pair<pair<ll,ll>,ll>,vector<pair<pair<ll,ll>,ll>>,greater<pair<pair<ll,ll>,ll>>> pq;
int k,q;
int main () {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        ll a,b,c; cin >> a >> b >> c;
        v[a].push_back({c,b});
    }
    cin >> k >> q;
    for(int j = 0; j < q; j++) {
        ll st,en; cin >> st >> en;
        for(int i = 0; i < 75; i++) {
            checked[i] = false;
            dp[i] = -1;
        }
        dp[st] = 0;
        pq.push({{0,st},0});
        while(!pq.empty()) {
            ll a = pq.top().first.first;
            ll b = pq.top().first.second;
            ll cnt = pq.top().second;
            pq.pop();
            /*if(checked[b]) continue;
            checked[b] = true;*/
            if(cnt >= k) continue;
            for(int i = 0; i < v[b].size(); i++) {
                if(dp[v[b][i].second] == -1 || dp[v[b][i].second] > a + v[b][i].first) {
                    dp[v[b][i].second] = max(0,a + v[b][i].first);
                    pq.push({{dp[v[b][i].second],v[b][i].second},cnt+1});
                }
            }
        }
        cout << dp[en] << endl;
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for(int i = 0; i < v[b].size(); i++) {
      |                            ~~^~~~~~~~~~~~~
Main.cpp:37:65: error: no matching function for call to 'max(int, ll)'
   37 |                     dp[v[b][i].second] = max(0,a + v[b][i].first);
      |                                                                 ^
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 Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:37:65: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   37 |                     dp[v[b][i].second] = max(0,a + v[b][i].first);
      |                                                                 ^
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 Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:37:65: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   37 |                     dp[v[b][i].second] = max(0,a + v[b][i].first);
      |                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Main.cpp:37:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |                     dp[v[b][i].second] = max(0,a + v[b][i].first);
      |                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Main.cpp:37:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |                     dp[v[b][i].second] = max(0,a + v[b][i].first);
      |                                                                 ^