Submission #589345

#TimeUsernameProblemLanguageResultExecution timeMemory
589345stevancvTravelling Merchant (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; vector<vector<int>> a(n, vector<int>(2 * k)); for (int i = 0; i < n; i++) { for (int j = 0; j < 2 * k; j++) { cin >> a[i][j]; } } vector<vector<ll>> dist(n, vector<ll>(n, 1e18)); for (int i = 0; i < m; i++) { int x, y, z; cin >> x >> y >> z; x -= 1; y -= 1; dist[x][y] = z; } for (int l = 0; l < n; l++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { smin(dist[i][j], dist[i][l] + dist[l][j]); } } } vector<vector<ll>> opt(n, vector<ll>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ll x = 0; for (int l = 0; l < k; l++) { if (a[i][2 * l] == -1 || a[j][2 * l + 1] == -1) continue; ll tx = a[j][2 * l + 1] - a[i][2 * l]; smax(x, tx); } opt[i][j] = x; } } auto Can = [&] (ll x) { vector<vector<ll>> d(n, vector<ll>(n, 1e18)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = x * min(dist[i][j], 1e18 / x) - opt[i][j]; for (int o = 0; o < n; o++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) smin(d[i][j], d[i][o] + d[o][j]); for (int i = 0; i < n; i++) if (d[i][i] <= 0) return true; return false; }; ll l = 0; ll r = 1e9; ll ans = 0; while (l <= r) { ll mid = l + r >> 1; if (Can(mid)) { ans = mid; l = mid + 1; } else r = mid - 1; } cout << ans << en; return 0; }

Compilation message (stderr)

merchant.cpp: In lambda function:
merchant.cpp:48:103: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, double)'
   48 |         for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = x * min(dist[i][j], 1e18 / x) - opt[i][j];
      |                                                                                                       ^
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 merchant.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
merchant.cpp:48:103: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   48 |         for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = x * min(dist[i][j], 1e18 / x) - opt[i][j];
      |                                                                                                       ^
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 merchant.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
merchant.cpp:48:103: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   48 |         for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = x * min(dist[i][j], 1e18 / x) - opt[i][j];
      |                                                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
merchant.cpp:48:103: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |         for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = x * min(dist[i][j], 1e18 / x) - opt[i][j];
      |                                                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
merchant.cpp:48:103: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |         for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = x * min(dist[i][j], 1e18 / x) - opt[i][j];
      |                                                                                                       ^
merchant.cpp: In function 'int main()':
merchant.cpp:56:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   56 |         ll mid = l + r >> 1;
      |                  ~~^~~