Submission #769385

#TimeUsernameProblemLanguageResultExecution timeMemory
769385AloraCommuter Pass (JOI18_commuter_pass)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; vector<vector<pair<int, int>>> g; void djikstra(int src, vector<long long> &sp) { priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq; sp[src] = 0; pq.push({0, src}); while (pq.size()) { int u = pq.top().second; pq.pop(); for (auto [v, w] : g[u]) if (sp[v] > sp[u] + w) sp[v] = sp[u] + w, pq.push({sp[v], v}); } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, S, T, U, V; cin >> n >> m >> S >> T >> U >> V; --S, --T, --U, --V; g.resize(n); for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; --a, --b; g[a].push_back({b, c}); g[b].push_back({a, c}); } vector<vector<long long>> sp(4, vector<long long> (n, INF)); djikstra(S, sp[0]); djikstra(T, sp[1]); djikstra(U, sp[2]); djikstra(V, sp[3]); long long d1 = INF, d2 = INF; for (int i = 0; i < n; i++) { if (sp[0][i] + sp[1][i] == sp[0][T]) { d1 = min(d1, sp[2][i]); d2 = min(d2, sp[3][i]); } } ll TH1 = min (sp[0][U] + sp[1][V], sp[0][V] + sp[1][U]); ll TH2 = d1 + d2; cout << min({TH1, TH2, sp[2][V]}); }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:46:5: error: 'll' was not declared in this scope
   46 |     ll TH1 = min (sp[0][U] + sp[1][V], sp[0][V] + sp[1][U]);
      |     ^~
commuter_pass.cpp:47:7: error: expected ';' before 'TH2'
   47 |     ll TH2 = d1 + d2;
      |       ^~~~
      |       ;
commuter_pass.cpp:48:18: error: 'TH1' was not declared in this scope
   48 |     cout << min({TH1, TH2, sp[2][V]});
      |                  ^~~
commuter_pass.cpp:48:23: error: 'TH2' was not declared in this scope
   48 |     cout << min({TH1, TH2, sp[2][V]});
      |                       ^~~
commuter_pass.cpp:48:37: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   48 |     cout << min({TH1, TH2, sp[2][V]});
      |                                     ^
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 commuter_pass.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:
commuter_pass.cpp:48:37: note:   candidate expects 2 arguments, 1 provided
   48 |     cout << min({TH1, TH2, sp[2][V]});
      |                                     ^
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 commuter_pass.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:
commuter_pass.cpp:48:37: note:   candidate expects 3 arguments, 1 provided
   48 |     cout << min({TH1, TH2, sp[2][V]});
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
/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: