제출 #409311

#제출 시각아이디문제언어결과실행 시간메모리
409311tranxuanbach여행하는 상인 (APIO17_merchant)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define endl '\n' #define fi first #define se second #define For(i, l, r) for (int i = l; i < r; i++) #define ForE(i, l, r) for (int i = l; i <= r; i++) #define FordE(i, l, r) for (int i = l; i >= r; i--) #define Fora(v, a) for (auto v: a) #define bend(a) a.begin(), a.end() #define isz(a) ((signed)a.size()) typedef long long ll; typedef long double ld; typedef pair <int, int> pii; typedef vector <int> vi; typedef vector <pii> vpii; typedef vector <vi> vvi; const int N = 1e2 + 5, K = 1e3 + 5, inf = 1e9 + 7; const ll infll = (ld)1e18 + 7; int n, m, k; int b[N][K], s[N][K]; ll adj[N][N]; ll dist[N][N]; void floyd_warshall(){ ForE(k, 1, n){ ForE(i, 1, n){ ForE(j, 1, n){ if (dist[i][j] > dist[i][k] + dist[k][j]){ dist[i][j] = dist[i][k] + dist[k][j]; } } } } } ll profit[N][N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("KEK.inp", "r", stdin); // freopen("KEK.out", "w", stdout); cin >> n >> m >> k; ForE(i, 1, n){ ForE(j, 1, k){ cin >> b[i][j] >> s[i][j]; } } ForE(i, 1, n){ ForE(j, 1, n){ adj[i][j] = infll; } } ForE(i, 1, m){ int u, v, w; cin >> u >> v >> w; adj[u][v] = w; } ForE(i, 1, n){ ForE(j, 1, n){ dist[i][j] = adj[i][j]; } } floyd_warshall(); ForE(i, 1, n){ ForE(j, 1, n){ adj[i][j] = dist[i][j]; } } ForE(i, 1, n){ ForE(j, 1, n){ ForE(kk, 1, k){ if (b[i][kk] != -1 and s[j][kk] != -1){ profit[i][j] = max(profit[i][j], s[j][kk] - b[i][kk]); } } } } int lo = 0, hi = inf; while (lo < hi){ int mid = (lo + hi + 1) >> 1; ForE(i, 1, n){ ForE(j, 1, n){ dist[i][j] = (ll)mid * min(adj[i][j], infll / mid) - profit[i][j]; } } floyd_warshall(); bool ck = 0; ForE(i, 1, n){ if (dist[i][i] <= 0){ ck = 1; } } if (ck){ lo = mid; } else{ hi = mid - 1; } } cout << lo << endl; } /* ==================================================+ INPUT: | --------------------------------------------------| --------------------------------------------------| ==================================================+ OUTPUT: | --------------------------------------------------| --------------------------------------------------| ==================================================+ */

컴파일 시 표준 에러 (stderr) 메시지

merchant.cpp: In function 'int main()':
merchant.cpp:82:73: error: no matching function for call to 'max(ll&, int)'
   82 |                     profit[i][j] = max(profit[i][j], s[j][kk] - b[i][kk]);
      |                                                                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:73: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   82 |                     profit[i][j] = max(profit[i][j], s[j][kk] - b[i][kk]);
      |                                                                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:73: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   82 |                     profit[i][j] = max(profit[i][j], s[j][kk] - b[i][kk]);
      |                                                                         ^
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:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   82 |                     profit[i][j] = max(profit[i][j], s[j][kk] - b[i][kk]);
      |                                                                         ^
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:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
merchant.cpp:82:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   82 |                     profit[i][j] = max(profit[i][j], s[j][kk] - b[i][kk]);
      |                                                                         ^