Submission #1318549

#TimeUsernameProblemLanguageResultExecution timeMemory
1318549peanutCommuter Pass (JOI18_commuter_pass)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, m; int S, T, U, V; vector<pair<int, int>> adj[maxn]; vector<long long> dijkstra(int so) { vector<long long> dist(n+1, LLONG_MAX); dist[so] = 0; priority_queue<pair<long long, int>> pq; pq.push({0, so}); while (!pq.empty()) { long long d = -pq.top().first; int y = pq.top().second; pq.pop(); if (d != dist[y]) continue; for (auto x : adj[y]) { if (d + x.second < dist[x.first]) { dist[x.first] = d + x.second; pq.push({-dist[x.first], x.first}); } } } return dist; } int main() { ios::sync_with_stdio(false); cin.tie(0); //freopen("PATH.INP", "r", stdin); //freopen("PATH.OUT", "w", stdout); cin >> n >> m >> S >> T >> U >> V; for (int i = 1; i <= m; ++i) { int u, v, w; cin >> u >> v >> w; adj[u].push_back({v, w}); adj[v].push_back({u, w}); } vector<long long> distU = dijkstra(U); vector<long long> distV = dijkstra(V); vector<long long> dist(n+1, LLONG_MAX), mindistU(n+1, LLONG_MAX), mindistV(n+1, LLONG_MAX); dist[S] = 0, mindistU[S] = distU[S], mindistV[S] = distV[S]; priority_queue<pair<long long, int>> pq; pq.push({0, s}); while (!pq.empty()) { long long d = -pq.top().first; int y = pq.top().second; pq.pop(); if (d != dist[y]) continue; for (auto x : adj[y]) { if (d + x.second < dist[x.first]) { dist[x.first] = d + x.second; mindistU[x.first] = min(mindistU[y], distU[x.first]); mindistV[x.first] = min(mindistV[y], distV[x.first]); pq.push({-dist[x.first], x.first}); } else if (d + x.second == dist[x.first]) { if (min(mindistU[y], distU[x.first]) + min(mindistV[y], distV[x.first]) < mindistU[x.first] + mindistV[x.first]) { mindistU[x.first] = min(mindistU[y], distU[x.first]); mindistV[x.first] = min(mindistV[y], distV[x.first]); } } } } cout << min(distU[V], mindistU[T] + mindistV[T]); return 0; }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:44:17: error: 's' was not declared in this scope
   44 |     pq.push({0, s});
      |                 ^
commuter_pass.cpp:44:12: error: no matching function for call to 'std::priority_queue<std::pair<long long int, int> >::push(<brace-enclosed initializer list>)'
   44 |     pq.push({0, s});
      |     ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/13/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
                 from commuter_pass.cpp:1:
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int>, std::allocator<std::pair<long long int, int> > >; _Compare = std::less<std::pair<long long int, int> >; value_type = std::pair<long long int, int>]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<long long int, int> >::value_type&' {aka 'const std::pair<long long int, int>&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int>, std::allocator<std::pair<long long int, int> > >; _Compare = std::less<std::pair<long long int, int> >; value_type = std::pair<long long int, int>]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, int> >::value_type&&' {aka 'std::pair<long long int, int>&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~