Submission #201643

#TimeUsernameProblemLanguageResultExecution timeMemory
201643waynetuinforOlympic Bus (JOI20_ho_t4)C++17
Compilation error
0 ms0 KiB
#include <algorithm> #include <array> #include <iostream> #include <queue> #include <vector> int main() { int n, m; std::cin >> n >> m; constexpr int kInf = 1'000'000'000; std::vector<std::vector<int>> dist(n, std::vector<int>(n, kInf)); for (int i = 0; i < n; ++i) dist[i][i] = 0; std::vector<std::array<int, 4>> ed(m); std::vector<std::vector<std::pair<int, int>>> g(n); for (int i = 0; i < m; ++i) { int u, v, c, d; std::cin >> u >> v >> c >> d; u--, v--; dist[u][v] = std::min(dist[u][v], c); ed[i] = {u, v, c, d}; g[u].emplace_back(v, i); } for (int k = 0; k < n; ++k) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]); } } } int64_t ans = dist[0][n - 1] + dist[n - 1][0]; auto Dijkstra = [&](int s, int e, int v) { std::vector<int> dist(n, kInf), used(n); std::priority_queue<std::pair<int, int>> pq; pq.emplace(0, s); dist[s] = 0; while (!pq.empty()) { int x = pq.top().second; pq.pop(); if (x == e) break; if (used[x]++) continue; for (auto i : g[x]) { int u = i.first, z = i.second; if (z == v) continue; if (dist[u] > dist[x] + ed[z][2]) { dist[u] = dist[x] + ed[z][2]; pq.emplace(-dist[u], u); } } if (x == ed[v][1]) { if (dist[ed[v][0]] > dist[x] + ed[v][2]) { dist[ed[v][0]] = dist[x] + ed[v][2]; pq.emplace(-dist[ed[v][0]], ed[v][0]); } } } return dist[e]; }; for (int i = 0; i < m; ++i) { int u = ed[i][0], v = ed[i][1], c = ed[i][2], d = ed[i][3]; int a = std::min(dist[0][n - 1], dist[0][v] + dist[u][n - 1] + c); int b = std::min(dist[n - 1][0], dist[n - 1][v] + dist[u][0] + c); if (0LL + a + b + d < ans) { int x = Dijkstra(0, n - 1, i); int y = Dijkstra(n - 1, 0, i); ans = std::min(ans, 0LL + x + y + d); } } if (ans >= kInf) ans = -1; std::cout << ans << "\n"; return 0; }

Compilation message (stderr)

ho_t4.cpp: In function 'int main()':
ho_t4.cpp:67:42: error: no matching function for call to 'min(int64_t&, long long int)'
       ans = std::min(ans, 0LL + x + y + d);
                                          ^
In file included from /usr/include/c++/7/algorithm:61:0,
                 from ho_t4.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:
ho_t4.cpp:67:42: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
       ans = std::min(ans, 0LL + x + y + d);
                                          ^
In file included from /usr/include/c++/7/algorithm:61:0,
                 from ho_t4.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:
ho_t4.cpp:67:42: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
       ans = std::min(ans, 0LL + x + y + d);
                                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from ho_t4.cpp:1:
/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:
ho_t4.cpp:67:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
       ans = std::min(ans, 0LL + x + y + d);
                                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from ho_t4.cpp:1:
/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:
ho_t4.cpp:67:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
       ans = std::min(ans, 0LL + x + y + d);
                                          ^