Submission #155106

#TimeUsernameProblemLanguageResultExecution timeMemory
155106mhy908Travelling Merchant (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define llinf 987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
int n, m, k;
LL buy[110][1010], sell[110][1010];
LL floyd[110][110];
LL cost[110][110];
LL edge[110][110];
bool negcycle()
{
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(edge[i][j]>edge[i][k]+edge[k][j]){
                    edge[i][j]=edge[i][k]+edge[k][j];
                }
            }
        }
    }
    bool ret=false;
    for(int i=1; i<=n; i++){
        if(edge[i][i]<=0)ret=true;
    }
    return ret;
}
LL binsearch(LL a, LL b){
    if(a==b)return a;
    LL mid=(a+b)/2+1;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            edge[i][j]=min(llinf, mid*floyd[i][j])-cost[i][j];
        }
    }
    if(negcycle())return binsearch(mid, b);
    return binsearch(a, mid-1);
}
int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=k; j++)
            scanf("%lld %lld", &buy[i][j], &sell[i][j]);
    for(int i=1; i<=n; i++)for(int j=1; j<=n; j++)floyd[i][j]=llinf;
    for(int i=1; i<=m; i++){
        int a, b;
        LL c;
        scanf("%d %d %lld", &a, &b, &c);
        floyd[a][b]=min(floyd[a][b], c);
    }
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(floyd[i][j]>floyd[i][k]+floyd[k][j]){
                    floyd[i][j]=floyd[i][k]+floyd[k][j];
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int z=1; z<=k; z++){
                if(sell[j][z]>=0&&buy[i][z]>=0)cost[i][j]=max(cost[i][j], sell[j][z]-buy[i][z]);
            }
        }
    }
    printf("%lld", binsearch(0, 2000000000));
}

Compilation message (stderr)

merchant.cpp: In function 'LL binsearch(LL, LL)':
merchant.cpp:36:50: error: no matching function for call to 'min(long int, LL)'
             edge[i][j]=min(llinf, mid*floyd[i][j])-cost[i][j];
                                                  ^
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:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
merchant.cpp:36:50: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'LL {aka long long int}')
             edge[i][j]=min(llinf, mid*floyd[i][j])-cost[i][j];
                                                  ^
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:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
merchant.cpp:36:50: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'LL {aka long long int}')
             edge[i][j]=min(llinf, mid*floyd[i][j])-cost[i][j];
                                                  ^
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:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
merchant.cpp:36:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
             edge[i][j]=min(llinf, mid*floyd[i][j])-cost[i][j];
                                                  ^
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:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
merchant.cpp:36:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
             edge[i][j]=min(llinf, mid*floyd[i][j])-cost[i][j];
                                                  ^
merchant.cpp: In function 'int main()':
merchant.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:47:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld %lld", &buy[i][j], &sell[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %lld", &a, &b, &c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~