Submission #956244

#TimeUsernameProblemLanguageResultExecution timeMemory
956244samvar_0907Olympic Bus (JOI20_ho_t4)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 201, M = 40001; int n, m; multiset<pair<int, int>> adj[N]; int c[M], d[M]; pair<int, int> edges[M]; vector<int> dijkstra(int source){ vector<int> dist(n + 1, 1e15); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; pq.push({0, source}); dist[source] = 0; while (!pq.empty()) { int u = pq.top().second; int d = pq.top().first; pq.pop(); for (auto &n : adj[u]){ if (dist[n.first] > d + c[n.second]){ dist[n.first] = d + c[n.second]; pq.push({dist[n.first], n.first}); } } } return dist; } signed main(){ cin >> n >> m; for (int i = 1; i <= n; ++i) { adj[i].clear(); } vector<vector<int>> dist(n + 1, vector<ll>(n + 1, 1e15)); for (ll i = 1; i <= n; ++i) { dist[i][i] = 0; } for (int i = 0; i < m; ++i){ int u, v; cin >> u >> v >> c[i] >> d[i]; adj[u].insert({v, i}); edges[i] = {u, v}; dist[u][v] = min(dist[u][v], c[i]); } // Floyd Warshall for (int k = 1; k <= n; ++k) { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } int ans = min(dist[1][n] + dist[n][1]); ll u = edges[i].first, v = edges[i].second; if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) + min(dist[n][1], dist[n][v] + c[i] + dist[u][1]) + d[i] < ans) { adj[u].erase(adj[u].find({v, i})); adj[v].insert({u, i}); ans = min(ans, d[i] + dijkstra(1)[n] + dijkstra(n)[1]); adj[v].erase(adj[v].find({edges[i].first, i})); adj[u].insert({v, i}); } if (ans == (int)(1e15)) { ans = -1; } cout << ans; }

Compilation message (stderr)

ho_t4.cpp: In function 'int main()':
ho_t4.cpp:38:44: error: 'll' was not declared in this scope
   38 |     vector<vector<int>> dist(n + 1, vector<ll>(n + 1, 1e15));
      |                                            ^~
ho_t4.cpp:38:46: error: template argument 1 is invalid
   38 |     vector<vector<int>> dist(n + 1, vector<ll>(n + 1, 1e15));
      |                                              ^
ho_t4.cpp:38:46: error: template argument 2 is invalid
ho_t4.cpp:39:12: error: expected ';' before 'i'
   39 |     for (ll i = 1; i <= n; ++i) {
      |            ^~
      |            ;
ho_t4.cpp:39:20: error: 'i' was not declared in this scope
   39 |     for (ll i = 1; i <= n; ++i) {
      |                    ^
ho_t4.cpp:60:42: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   60 |     int ans = min(dist[1][n] + dist[n][1]);
      |                                          ^
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 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:60:42: note:   candidate expects 2 arguments, 1 provided
   60 |     int ans = min(dist[1][n] + dist[n][1]);
      |                                          ^
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 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:60:42: note:   candidate expects 3 arguments, 1 provided
   60 |     int ans = min(dist[1][n] + dist[n][1]);
      |                                          ^
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:60:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     int ans = min(dist[1][n] + dist[n][1]);
      |                                          ^
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:60:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     int ans = min(dist[1][n] + dist[n][1]);
      |                                          ^
ho_t4.cpp:61:7: error: expected ';' before 'u'
   61 |     ll u = edges[i].first, v = edges[i].second;
      |       ^~
      |       ;
ho_t4.cpp:63:33: error: 'v' was not declared in this scope
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                                 ^
ho_t4.cpp:63:40: error: 'i' was not declared in this scope
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                                        ^
ho_t4.cpp:63:50: error: 'u' was not declared in this scope
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                                                  ^