제출 #934218

#제출 시각아이디문제언어결과실행 시간메모리
934218oblantis여행하는 상인 (APIO17_merchant)C++17
컴파일 에러
0 ms0 KiB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; typedef long long ll; typedef pair<int, int> pii; const int inf = 2e9; const int mod = 1e9+7; const int maxn = 100 + 1; int to[maxn][maxn]; void solve() { int n, m, k; cin >> n >> m >> k; int b[n][k], s[n][k]; int p[n][n], dist[n][n]; vt<pii> g[n]; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++)p[i][j] = -1, dist[i][j] = inf; for(int j = 0; j < k; j++){ cin >> b[i][j] >> s[i][j]; } } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ for(int o = 0; o < k; o++){ if(b[i][o] != -1)to[i][j] = max(to[i][j], s[j][o] - b[i][o]); } } } for(int i = 0, u, v, d; i < m; i++){ cin >> u >> v >> d; --u, --v; g[u].pb({v, d}); } for(int i = 0; i < n; i++){ priority_queue<pii, vt<pii>, greater<pii>> pq; pq.push({0, i}); dist[i][i] = 0, p[i][i] = i; while(!pq.empty()){ pii nw = pq.top(); pq.pop(); if(dist[i][nw.ss] != nw.ff)continue; for(auto j : g[nw.ss]){ if(dist[i][j.ff] > nw.ff + j.ss){ dist[i][j.ff] = nw.ff + j.ss; p[i][j.ff] = nw.ss; pq.push({dist[i][j.ff], j.ff}); } } } } int ans = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(i == j || dist[i][j] == inf || dist[j][i] == inf)continue; int x = i, dd = dist[i][j] + dist[j][i]; vt<int> path; while(x != j){ path.pb(x); x = p[j][x]; } while(x != i){ path.pb(x); x = p[i][x]; } path.pb(i); reverse(all(path)); int sz = path.size(); vt<ll> dp(sz, 0); for(int o = 1; o < sz; o++){ dp[o] = dp[o - 1]; for(int j = 0; j < o; j++){ dp[o] = max(dp[o], dp[j] + to[path[j]][path[o]]); } } ans = max(ans, (dp[sz - 1] + dd - 1) / dd); } } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int times = 1; //cin >> times; for(int i = 1; i <= times; i++) { solve(); } return 0; }

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

merchant.cpp: In function 'void solve()':
merchant.cpp:81:45: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   81 |    ans = max(ans, (dp[sz - 1] + dd - 1) / dd);
      |                                             ^
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:3:
/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:81:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   81 |    ans = max(ans, (dp[sz - 1] + dd - 1) / dd);
      |                                             ^
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:3:
/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:81:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   81 |    ans = max(ans, (dp[sz - 1] + dd - 1) / dd);
      |                                             ^
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:3:
/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:81:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |    ans = max(ans, (dp[sz - 1] + dd - 1) / dd);
      |                                             ^
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:3:
/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:81:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |    ans = max(ans, (dp[sz - 1] + dd - 1) / dd);
      |                                             ^