Submission #286636

#TimeUsernameProblemLanguageResultExecution timeMemory
286636valerikkOlympic 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 = 205, M = 5e4 + 7; const long long INF = 1e18 + 39; struct Edge{ int v, u; long long c, d; Edge() {} Edge(int v, int u, long long c, long long d) : v(v), u(u), c(c), d(d) {} }; int n ,m; Edge edg[M]; void dijks(int st, long long d[], int p[], bool rev, vector<int> g[], int ign) { for (int i = 0; i < n; ++i) { d[i] = INF; p[i] = -1; } d[st] = 0; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q; q.push({d[st], st}); while (!q.empty()) { auto cur = q.top(); q.pop(); int v = cur.second; if (d[v] != cur.first) continue; for (auto id : g[v]) { if (id == ign) continue; int w = edg[id].c, u = rev ? edg[id].v : edg[id].u; if (d[v] + w < d[u]) { d[u] = d[v] + w; p[u] = id; q.push({d[u], u}); } } } } vector<int> g[N], gr[N]; long long d1[N], dn[N]; long long d1r[N], dnr[N]; int p1[N], pn[N]; int p1r[N], pnr[N]; bool bad1[M], badn[M]; bool bad1r[M], badnr[M]; long long tmp_d[N], tmp_p[N]; int get_d1(int v, int ign) { if (bad1[ign]) { dijks(0, tmp_d, tmp_p, 0, g, ign); return tmp_d[v]; } return d1[v]; } int get_dn(int v, int ign) { if (badn[ign]) { dijks(n - 1, tmp_d, tmp_p, 0, g, ign); return tmp_d[v]; } return dn[v]; } int get_d1r(int v, int ign) { if (bad1r[ign]) { dijks(0, tmp_d, tmp_p, 1, gr, ign); return tmp_d[v]; } return d1r[v]; } int get_dnr(int v, int ign) { if (badnr[ign]) { dijks(n - 1, tmp_d, tmp_p, 1, gr, ign); return tmp_d[v]; } return dnr[v]; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> edg[i].v >> edg[i].u >> edg[i].c >> edg[i].d; edg[i].v--; edg[i].u--; g[edg[i].v].push_back(i); gr[edg[i].u].push_back(i); } dijks(0, d1, p1, 0, g, -1); dijks(0, d1r, p1r, 1, gr, -1); dijks(n - 1, dn, pn, 0, g, -1); dijks(n - 1, dnr, pnr, 1, gr, -1); for (int i = 0; i < n; ++i) { if (~p1[i]) bad1[p1[i]] = 1; if (~pn[i]) badn[pn[i]] = 1; if (~p1r[i]) bad1r[p1r[i]] = 1; if (~pnr[i]) badnr[pnr[i]] = 1; } int ans = min(INF, d1[n - 1] + dn[0]); for (int i = 0; i < m; ++i) { int dist1 = min(get_d1(n - 1, i), get_d1(edg[i].u, i) + get_dnr(edg[i].v, i) + edg[i].c); int distn = min(get_dn(0, i), get_dn(edg[i].u, i) + get_d1r(edg[i].v, i) + edg[i].c); ans = min(ans, dist1 + distn + edg[i].d); } if (ans == INF) cout << "-1\n"; else cout << ans << '\n'; return 0; }

Compilation message (stderr)

ho_t4.cpp: In function 'int get_d1(int, int)':
ho_t4.cpp:54:25: error: cannot convert 'long long int*' to 'int*'
   54 |         dijks(0, tmp_d, tmp_p, 0, g, ign);
      |                         ^~~~~
      |                         |
      |                         long long int*
ho_t4.cpp:17:39: note:   initializing argument 3 of 'void dijks(int, long long int*, int*, bool, std::vector<int>*, int)'
   17 | void dijks(int st, long long d[], int p[], bool rev, vector<int> g[], int ign) {
      |                                   ~~~~^~~
ho_t4.cpp: In function 'int get_dn(int, int)':
ho_t4.cpp:62:29: error: cannot convert 'long long int*' to 'int*'
   62 |         dijks(n - 1, tmp_d, tmp_p, 0, g, ign);
      |                             ^~~~~
      |                             |
      |                             long long int*
ho_t4.cpp:17:39: note:   initializing argument 3 of 'void dijks(int, long long int*, int*, bool, std::vector<int>*, int)'
   17 | void dijks(int st, long long d[], int p[], bool rev, vector<int> g[], int ign) {
      |                                   ~~~~^~~
ho_t4.cpp: In function 'int get_d1r(int, int)':
ho_t4.cpp:70:25: error: cannot convert 'long long int*' to 'int*'
   70 |         dijks(0, tmp_d, tmp_p, 1, gr, ign);
      |                         ^~~~~
      |                         |
      |                         long long int*
ho_t4.cpp:17:39: note:   initializing argument 3 of 'void dijks(int, long long int*, int*, bool, std::vector<int>*, int)'
   17 | void dijks(int st, long long d[], int p[], bool rev, vector<int> g[], int ign) {
      |                                   ~~~~^~~
ho_t4.cpp: In function 'int get_dnr(int, int)':
ho_t4.cpp:78:29: error: cannot convert 'long long int*' to 'int*'
   78 |         dijks(n - 1, tmp_d, tmp_p, 1, gr, ign);
      |                             ^~~~~
      |                             |
      |                             long long int*
ho_t4.cpp:17:39: note:   initializing argument 3 of 'void dijks(int, long long int*, int*, bool, std::vector<int>*, int)'
   17 | void dijks(int st, long long d[], int p[], bool rev, vector<int> g[], int ign) {
      |                                   ~~~~^~~
ho_t4.cpp: In function 'int main()':
ho_t4.cpp:111:96: error: no matching function for call to 'min(int, long long int)'
  111 |         int dist1 = min(get_d1(n - 1, i), get_d1(edg[i].u, i) + get_dnr(edg[i].v, i) + edg[i].c);
      |                                                                                                ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:111:96: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  111 |         int dist1 = min(get_d1(n - 1, i), get_d1(edg[i].u, i) + get_dnr(edg[i].v, i) + edg[i].c);
      |                                                                                                ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:111:96: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  111 |         int dist1 = min(get_d1(n - 1, i), get_d1(edg[i].u, i) + get_dnr(edg[i].v, i) + edg[i].c);
      |                                                                                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:111:96: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  111 |         int dist1 = min(get_d1(n - 1, i), get_d1(edg[i].u, i) + get_dnr(edg[i].v, i) + edg[i].c);
      |                                                                                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:111:96: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  111 |         int dist1 = min(get_d1(n - 1, i), get_d1(edg[i].u, i) + get_dnr(edg[i].v, i) + edg[i].c);
      |                                                                                                ^
ho_t4.cpp:112:92: error: no matching function for call to 'min(int, long long int)'
  112 |         int distn = min(get_dn(0, i), get_dn(edg[i].u, i) + get_d1r(edg[i].v, i) + edg[i].c);
      |                                                                                            ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:112:92: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  112 |         int distn = min(get_dn(0, i), get_dn(edg[i].u, i) + get_d1r(edg[i].v, i) + edg[i].c);
      |                                                                                            ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:112:92: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  112 |         int distn = min(get_dn(0, i), get_dn(edg[i].u, i) + get_d1r(edg[i].v, i) + edg[i].c);
      |                                                                                            ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:112:92: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  112 |         int distn = min(get_dn(0, i), get_dn(edg[i].u, i) + get_d1r(edg[i].v, i) + edg[i].c);
      |                                                                                            ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:112:92: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  112 |         int distn = min(get_dn(0, i), get_dn(edg[i].u, i) + get_d1r(edg[i].v, i) + edg[i].c);
      |                                                                                            ^
ho_t4.cpp:113:48: error: no matching function for call to 'min(int&, long long int)'
  113 |         ans = min(ans, dist1 + distn + edg[i].d);
      |                                                ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:113:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  113 |         ans = min(ans, dist1 + distn + edg[i].d);
      |                                                ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:113:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  113 |         ans = min(ans, dist1 + distn + edg[i].d);
      |                                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:113:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  113 |         ans = min(ans, dist1 + distn + edg[i].d);
      |                                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:113:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  113 |         ans = min(ans, dist1 + distn + edg[i].d);
      |                                                ^