Submission #155105

#TimeUsernameProblemLanguageResultExecution timeMemory
155105arnold518Travelling Merchant (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 100; const int MAXM = 9900; const int MAXK = 1000; const ll INF = 1e12; int N, M, K; int B[MAXN+10][MAXK+10], S[MAXN+10][MAXK+10]; ll dist[MAXN+10][MAXN+10], adj[MAXN+10][MAXN+10], A[MAXN+10][MAXN+10];; bool decide(ll X) { int i, j, k; for(i=1; i<=N; i++) for(j=1; j<=N; j++) adj[i][j]=X*dist[i][j]-A[i][j]; /* for(i=1; i<=N; i++) { for(j=1; j<=N; j++) printf("%lld ", adj[i][j]); printf("\n"); } printf("====================%lld\n", X); */ for(k=1; k<=N; k++) for(i=1; i<=N; i++) for(j=1; j<=N; j++) if(adj[i][k]!=INF && adj[k][j]!=INF) adj[i][j]=min(adj[i][k]+adj[k][j], adj[i][j]); /* for(i=1; i<=N; i++) { for(j=1; j<=N; j++) printf("%lld ", adj[i][j]); printf("\n"); } printf("====================!%lld\n", X);*/ for(i=1; i<=N; i++) if(adj[i][i]<0) return true; for(i=1; i<=N; i++) for(j=1; j<=N; j++) if(i!=j && adj[i][j]+adj[j][i]<=0) return true; return false; } int main() { int i, j, k; scanf("%d%d%d", &N, &M, &K); for(i=1; i<=N; i++) for(j=1; j<=K; j++) scanf("%d%d", &B[i][j], &S[i][j]); for(i=1; i<=N; i++) for(j=1; j<=N; j++) dist[i][j]=INF; for(i=1; i<=N; i++) dist[i][i]=0; for(i=1; i<=M; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); dist[u][v]=w; } for(i=1; i<=N; i++) for(j=1; j<=N; j++) { if(i==j) { for(k=1; k<=K; k++) if(B[i][k]!=-1 && S[j][k]!=-1) A[i][j]+=max(S[j][k]-B[i][k], 0); } else { for(k=1; k<=K; k++) if(B[i][k]!=-1 && S[j][k]!=-1) A[i][j]=max(A[i][j], S[j][k]-B[i][k]); } } for(k=1; k<=N; k++) for(i=1; i<=N; i++) for(j=1; j<=N; j++) if(dist[i][k]!=INF && dist[k][j]!=INF) dist[i][j]=min(dist[i][k]+dist[k][j], dist[i][j]); ll lo=0, hi=1e15; while(lo+1<hi) { ll mid=lo+hi>>1; if(decide(mid)) lo=mid; else hi=mid; } printf("%lld", lo); }

Compilation message (stderr)

merchant.cpp: In function 'int main()':
merchant.cpp:68:100: error: no matching function for call to 'max(ll&, int)'
             for(k=1; k<=K; k++) if(B[i][k]!=-1 && S[j][k]!=-1) A[i][j]=max(A[i][j], S[j][k]-B[i][k]);
                                                                                                    ^
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:68:100: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             for(k=1; k<=K; k++) if(B[i][k]!=-1 && S[j][k]!=-1) A[i][j]=max(A[i][j], S[j][k]-B[i][k]);
                                                                                                    ^
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:68:100: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             for(k=1; k<=K; k++) if(B[i][k]!=-1 && S[j][k]!=-1) A[i][j]=max(A[i][j], S[j][k]-B[i][k]);
                                                                                                    ^
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:68:100: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             for(k=1; k<=K; k++) if(B[i][k]!=-1 && S[j][k]!=-1) A[i][j]=max(A[i][j], S[j][k]-B[i][k]);
                                                                                                    ^
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:68:100: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             for(k=1; k<=K; k++) if(B[i][k]!=-1 && S[j][k]!=-1) A[i][j]=max(A[i][j], S[j][k]-B[i][k]);
                                                                                                    ^
merchant.cpp:77:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         ll mid=lo+hi>>1;
                ~~^~~
merchant.cpp:47: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:48:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) for(j=1; j<=K; j++) scanf("%d%d", &B[i][j], &S[i][j]);
                                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &u, &v, &w);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~