Submission #249582

#TimeUsernameProblemLanguageResultExecution timeMemory
249582godwindTravelling Merchant (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <random> #include <set> #include <map> #include <queue> #include <cstring> #include <cmath> #include <bitset> #include <iomanip> #include <functional> //#include <unordered_map> using namespace std; template<typename T> void uin(T &a, T b) {if (b < a) a = b;} template<typename T> void uax(T &a, T b) {if (b > a) a = b;} #define int long long #define double long double #define left left228 #define right right228 #define mp make_pair #define all(v) v.begin(), v.end() const int N = 105, K = 1005; const double eps = 1e-6; const int INF = 1e18 + 228; int n, m, k; int buy[N][K], sell[N][K]; vector< pair<int, int> > g[N]; int dist[N][N]; int max_profit[N][N]; void pre() { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { dist[i][j] = INF; } dist[i][i] = 0; } for (int v = 1; v <= n; ++v) { for (pair<int, int> go : g[v]) { int to = go.first; int w = go.second; uin(dist[v][to], w); } } for (int k = 1; k <= n; ++k) { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (dist[i][k] < INF && dist[k][j] < INF) { uin(dist[i][j], dist[i][k] + dist[k][j]); } } } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { for (int t = 1; t <= k; ++t) { if (buy[i][t] != -1 && sell[j][t] != -1) { uax(max_profit[i][j], sell[j][t] - buy[i][t]); } } } } } double d[N], d2[N]; bool Gr(double x, double y) { return x > y + eps; } struct edge { int from, to; double w; edge() {} edge(int _from, int _to, double _w) { from = _from; to = _to; w = _w; } }; bool check(double x) { vector< edge > edges; for (int a = 1; a <= n; ++a) { for (int b = 1; b <= n; ++b) { if (dist[a][b] < INF) { double weight = (double)max_profit[a][b] - (double)dist[a][b] * x; edges.emplace_back( a, b, min(INF, -weight) ); } } } for (int i = 1; i <= n; ++i) { d[i] = INF; } d[1] = 0; int V = -1; for (int it = 0; it < n; ++it) { V = -1; for (auto e : edges) { if (d[ e.from ] + e.w + eps < d[e.to]) { d[e.to] = d[e.from] + e.w; V = e.to; } } } if (V == -1) return 0; return 1; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m >> k; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= k; ++j) { cin >> buy[i][j] >> sell[i][j]; } } for (int i = 0; i < m; ++i) { int u, v, w; cin >> u >> v >> w; g[u].emplace_back(v, w); } pre(); double l = 0, r = 1e10; for (int i = 0; i < 100; ++i) { if (abs(r - l) <= eps) break; double M = (l + r) / 2.0; if (check(M)) { l = M; } else { r = M; } } cout << setprecision(15) << (int)r << '\n'; return 0; } /* */

Compilation message (stderr)

merchant.cpp: In function 'bool check(long double)':
merchant.cpp:97:59: error: no matching function for call to 'min(const long long int&, long double)'
                 edges.emplace_back( a, b, min(INF, -weight) );
                                                           ^
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/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 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:97:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long double')
                 edges.emplace_back( a, b, min(INF, -weight) );
                                                           ^
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/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 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:97:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long double')
                 edges.emplace_back( a, b, min(INF, -weight) );
                                                           ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from merchant.cpp:3:
/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:97:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 edges.emplace_back( a, b, min(INF, -weight) );
                                                           ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from merchant.cpp:3:
/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:97:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 edges.emplace_back( a, b, min(INF, -weight) );
                                                           ^