Submission #518614

#TimeUsernameProblemLanguageResultExecution timeMemory
518614KhoaHoRobot (JOI21_ho_t4)C++11
Compilation error
0 ms0 KiB
/// KoJa #include <bits/stdc++.h> using namespace std; #define task "QG04PAINT" #define pb push_back #define SZ(a) (a).begin(), (a).end() #define SZZ(a, Begin, End) (a) + (Begin), (a) + (Begin) + (End) #define BIT(a) (1LL << (a)) #define vec vector #define fi first #define se second typedef long long ll; typedef pair<ll, int> ii; template <class T> inline bool maximize(T &a, const T &b) { return (a < b ? (a = b) : 0); } template <class T> inline bool minimize(T &a, const T &b) { return (a > b ? (a = b) : 0); } void init() { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } void fastio() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); } const int N = int(2e5) + 1000; const ll INF = 1e18; int n, m; ll dist[N], best[N], sum[N]; struct Edge { int to, c; ll cost; Edge(int _to = 0, int _c = 0, ll _cost = 0) { to = _to; c = _c; cost = _cost; } }; vec<Edge> adj[N]; int main() { fastio(); cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v, c; ll cost; cin >> u >> v >> c >> cost; adj[u].pb(Edge(v, c, cost)); adj[v].pb(Edge(u, c, cost)); } for (int i = 1; i <= n; i++) dist[i] = INF; for (int i = 1; i <= m; i++) { best[i] = INF; sum[i] = 0; } dist[1] = 0; priority_queue<ii> q; q.push(ii(0, 1)); while (!q.empty()) { int u = q.top().se; ll du = -q.top().fi; // cout << u << " " << -du << '\n'; q.pop(); if (du != dist[u]) continue; for (Edge x : adj[u]) { sum[x.c] += x.cost; best[x.c] = min(best[x.c], dist[x.to]); } for (Edge x : adj[u]) { int v = x.to; int c = x.c; int cost = x.cost; ll tmp = min(cost, sum[c] - cost); if (minimize(dist[v], tmp + du)) q.push(ii(-dist[v], v)); if (minimize(dist[v], best[c] + sum[c] - cost)) q.push(ii(-dist[v], v)); } for (Edge x : adj[u]) { sum[x.c] = 0; best[x.c] = INF; } } if (dist[n] == INF) dist[n] = -1; cout << dist[n]; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:89:45: error: no matching function for call to 'min(int&, ll)'
   89 |             ll tmp = min(cost, sum[c] - cost);
      |                                             ^
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 Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> 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:
Main.cpp:89:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   89 |             ll tmp = min(cost, sum[c] - cost);
      |                                             ^
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 Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> 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:
Main.cpp:89:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   89 |             ll tmp = min(cost, sum[c] - cost);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> _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:
Main.cpp:89:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   89 |             ll tmp = min(cost, sum[c] - cost);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> _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:
Main.cpp:89:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   89 |             ll tmp = min(cost, sum[c] - cost);
      |                                             ^
Main.cpp: In function 'void init()':
Main.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(task ".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen(task ".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~