Submission #736886

#TimeUsernameProblemLanguageResultExecution timeMemory
736886stevancvOlympic Bus (JOI20_ho_t4)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; const int N = 200 + 2; const int M = 5e4 + 2; const ll linf = 1e18; ll dist[N][N], di[N]; pair<int, int> prv[N]; vector<pair<int, int>> g[N]; int u[M], v[M], c[M], d[M], is[M], n, m; void Dijkstra(int x) { for (int i = 0; i < n; i++) di[i] = linf; vector<int> was(n); priority_queue<pair<ll, int>> pq; di[x] = 0; pq.push({0, x}); while (!pq.empty()) { ll v = -pq.top().first; int s = pq.top().second; pq.pop(); if (was[s] == 1) continue; was[s] = 1; for (auto zz : g[s]) { int u = zz.first; int i = zz.second; if (di[u] > v + c[i]) { di[u] = v + c[i]; prv[u] = {s, i}; pq.push({-di[u], u}); } } } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) dist[i][j] = linf; for (int i = 0; i < m; i++) { cin >> u[i] >> v[i] >> c[i] >> d[i]; u[i] -= 1; v[i] -= 1; smin(dist[u[i]][v[i]], c[i]); g[u[i]].push_back({v[i], i}); } for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) smin(dist[i][j], dist[i][k] + dist[k][j]); Dijkstra(0); if (di[n - 1] != linf) { int x = n - 1; while (x > 0) { is[prv[x].second] = 1; x = prv[x].first; } } Dijkstra(n - 1); if (di[0] != linf) { int x = 0; while (x < n - 1) { is[prv[x].second] = 1; x = prv[x].first; } } ll ans = linf; if (dist[0][n - 1] != linf && dist[n - 1][0] != linf) ans = dist[0][n - 1] + dist[n - 1][0]; for (int i = 0; i < m; i++) { if (is[i] == 0) { ll d1 = min(dist[0][n - 1], dist[0][v[i]] + c[i] + dist[u[i]][n - 1]); ll d2 = min(dist[n - 1][0], dist[n - 1][v[i]] + c[i] + dist[u[i]][0]); if (d1 < linf && d2 < linf) smin(ans, d1 + d2 + d[i]); continue; } for (int j = 0; j < n; j++) g[i].clear(); for (int j = 0; j < m; j++) { if (i == j) g[v[j]].push_back({u[j], j}); else g[u[j]].push_back({v[j], j}); } ll ret = d[i]; Dijkstra(0); if (di[n - 1] == linf) continue; ret += di[n - 1]; Dijkstra(n - 1); if (di[0] == linf) continue; ret += di[0]; smin(ans, ret); } if (ans == linf) ans = -1; cout << ans << en; return 0; }

Compilation message (stderr)

ho_t4.cpp: In function 'int main()':
ho_t4.cpp:6:32: error: no matching function for call to 'min(long long int&, int&)'
    6 | #define smin(a, b) a = min(a, b)
      |                                ^
ho_t4.cpp:47:9: note: in expansion of macro 'smin'
   47 |         smin(dist[u[i]][v[i]], c[i]);
      |         ^~~~
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 ho_t4.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:
ho_t4.cpp:6:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    6 | #define smin(a, b) a = min(a, b)
      |                                ^
ho_t4.cpp:47:9: note: in expansion of macro 'smin'
   47 |         smin(dist[u[i]][v[i]], c[i]);
      |         ^~~~
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 ho_t4.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:
ho_t4.cpp:6:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    6 | #define smin(a, b) a = min(a, b)
      |                                ^
ho_t4.cpp:47:9: note: in expansion of macro 'smin'
   47 |         smin(dist[u[i]][v[i]], c[i]);
      |         ^~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t4.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:
ho_t4.cpp:6:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    6 | #define smin(a, b) a = min(a, b)
      |                                ^
ho_t4.cpp:47:9: note: in expansion of macro 'smin'
   47 |         smin(dist[u[i]][v[i]], c[i]);
      |         ^~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t4.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:
ho_t4.cpp:6:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    6 | #define smin(a, b) a = min(a, b)
      |                                ^
ho_t4.cpp:47:9: note: in expansion of macro 'smin'
   47 |         smin(dist[u[i]][v[i]], c[i]);
      |         ^~~~