Submission #1167702

#TimeUsernameProblemLanguageResultExecution timeMemory
1167702herissonwowCommuter Pass (JOI18_commuter_pass)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define ll long long
#define ld long double
#define en exit(0);
#define pb push_back
#define fi first
#define se second

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5+5;
const ll INF = 1e18+5;

int main()
{
    //ios_base()::sync_with_stdio(false); cin.tie(0);
    int n, m, s, t, u, v; cin >> n >> m >> s >> t >> u >> v;
    int trains[n+1][n+1];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <=n; j++){
            trains[i][j] = INF;
        }
    }
    for(int i = 0; i < n; i++){
        ll a, b, c; cin >> a >> b >> c;
        trains[a][b] = c;
        trains[b][a] = c;
    }
    bool marked[n+1];
    for(int caur = 1; caur <= n; caur++){
        for(int no = 1; no <=n; no++){
            for(int uz = 1; uz<=n; uz++){
                trains[no][uz] = min(trains[no][caur] + trains[caur][uz], trains[no][uz]);
            }
        }
    }
    ll TOT = trains[s][t];
    for(int i = 1; i <= n; i++){
        if(trains[s][i]+trains[i][t]==TOT)
            marked[i] = 1;
    }
    ll res = INF;
    for(int i = 1; i <= n; i++){
        if(marked[i])
            res = min(res, trains[i][v]);
    }
    cout << res;

    return 0;
}

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:24:28: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   24 |             trains[i][j] = INF;
      |                            ^~~
commuter_pass.cpp:48:22: error: no matching function for call to 'min(long long int&, int&)'
   48 |             res = min(res, trains[i][v]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~
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 commuter_pass.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:
commuter_pass.cpp:48:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   48 |             res = min(res, trains[i][v]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~
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 commuter_pass.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:
commuter_pass.cpp:48:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   48 |             res = min(res, trains[i][v]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~
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 commuter_pass.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:
commuter_pass.cpp:48:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |             res = min(res, trains[i][v]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~
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 commuter_pass.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:
commuter_pass.cpp:48:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |             res = min(res, trains[i][v]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~