Submission #250741

#TimeUsernameProblemLanguageResultExecution timeMemory
250741balbit여행하는 상인 (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define int ll
#define pii pair<int, int>
#define f first
#define s second

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S&&...y){cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define bug(...)
#endif // BALBIT

#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

const int maxn = 2e5+5;

int n,m,k;

ll B[102][1002], S[102][1002];
vector<pii> g[102];
ll d[102][1002];

bool bellmango(int start, int mid) {
    memset(d, 0x3f, sizeof d);
    d[start][0] = 0;
    for (int cnt = 0; cnt<n*3; ++cnt) {
        bool upd = 0;
        for (int v = 0; v<n; ++v) {
            for (int j = 0; j<=k; ++j) {
                if (d[v][j] == 0x3f3f3f3f3f3f3f3f) continue;
                for (pii & p : g[v]) {
                    if (d[p.f][j] > d[v][j] + mid * (ll)p.s) {
                        d[p.f][j] = d[v][j] + mid * (ll)p.s; upd = 1;
                    }
                }
                if (j == 0) {
                    for (int j2 = 1; j2<=k; ++j2) {
                        if (B[v][j2] != -1 && d[v][j2] > d[v][j] + B[v][j2]) {
                            d[v][j2] = d[v][j] + B[v][j2]; upd = 1;
                        }
                    }
                }else{
                    if (S[v][j] != -1 && d[v][0] > d[v][j] - S[v][j]){
                        d[v][0] = d[v][j] - S[v][j]; upd = 1;
                    }

                }
            }
        }
        if (!upd) {
            bug(mid, "No");
            return 0;
        }
    }
    bug(mid, "Works");
    return 1;
}

ll gdst[102][102];
ll deal[102][102];
ll F[102][102];
bool floydgo(int mid){
    memset(F, 0x3f, sizeof F);
    for (int i = 0; i<n; ++i) F[i][i] = 0;
    for (int i = 0; i<n; ++i) {
        for (int j = 0; j<n; ++j) {
            F[i][j] = min(F[i][j], deal[i][j] + mid * gdst[i][j]);
        }
    }
    for (int K = 0; K<n; ++K){
        for (int i = 0; i<n; ++i) {
            for (int j = 0; j<n; ++j) {
                F[i][j] = min(F[i][j], F[i][K] + F[K][j]);
            }
        }
    }
    for (int i = 0; i<n; ++i) {
        if (F[i][i] < 0) return 1;
        for (int j = 0; j<n; ++j) {
            if (j != i && F[i][j] + F[j][i] <=0) {
                return 1;
            }
        }
    }
    return 0;
}


signed main(){
    IOS();
    cin>>n>>m>>k;
    for (int i = 0; i<n; ++i) {
        for (int j = 0; j<k*2; ++j) {
            cin>>(j%2==0?B:S)[i][(j/2)+1];
        }
    }
    for (int i =0 ; i<n; ++i) {
        for (int j = 0; j<n; ++j) {
            for (int K = 1; K<=k; ++K) {
                if (B[i][K] != -1 && S[j][K] != -1) {
                    deal[i][j] = min(deal[i][j], B[i][K] - S[j][K]);
                }
            }
        }
    }
    memset(gdst, 0x3f, sizeof gdst);
    for (int i =0 ; i<n; ++i) gdst[i][i] = 0;
    for (int i = 0; i<m; ++i) {
        int a,b,c; cin>>a>>b>>c;
        g[a-1].pb({b-1,c});
        gdst[a-1][b-1] = min(gdst[a-1][b-1], (ll)c);
    }
    for (int K = 0; K<n; ++K){
        for (int i = 0; i<n; ++i) {
            for (int j = 0; j<n; ++j) {
                gdst[i][j] = min(gdst[i][j], gdst[i][K] + gdst[K][j]);
            }
        }
    }
    int l = 0, r = 1e9+1;
    while (l!=r) {
        int mid = (l+r)/2;
        if (floydgo(mid)) {
            l = mid+1;
        }else{
            r = mid;
        }
        bug(l,r);
    }
    cout<<max(l-1,0)<<endl;
}

Compilation message (stderr)

merchant.cpp: In function 'int main()':
merchant.cpp:140:20: error: no matching function for call to 'max(long long int, int)'
     cout<<max(l-1,0)<<endl;
                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from merchant.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
merchant.cpp:140:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
     cout<<max(l-1,0)<<endl;
                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from merchant.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
merchant.cpp:140:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
     cout<<max(l-1,0)<<endl;
                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
merchant.cpp:140:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
     cout<<max(l-1,0)<<endl;
                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
merchant.cpp:140:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
     cout<<max(l-1,0)<<endl;
                    ^