Submission #1109568

#TimeUsernameProblemLanguageResultExecution timeMemory
1109568nh0902Robot (JOI21_ho_t4)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 110000; long long const inf = 1e18; int n, m; struct Edge { int a, c; long long p; }; vector<Edge> v[N]; map<int, long long> ma[N]; long long dp[N]; map<int, long long> D[N]; struct Node { int x; long long d; int c; long long p; int pa; }; struct cmp{ bool operator() (Node u, Node v) { return u.d > v.d; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; int a, b, c; long long p; for (int i = 1; i <= m; i ++) { cin >> a >> b >> c >> p; v[a].push_back({b, c, p}); v[b].push_back({a, c, p}); ma[a][c] += p; ma[b][c] += p; } priority_queue<Node, vector<Node>, cmp> pq; for (int i = 2; i <= n; i ++) { for (Edge e : v[i]) { D[i][e.c] = inf; } dp[i] = inf; } dp[1] = 0; pq.push({1, 0, 0, 0, 0}); while (!pq.empty()) { Node t = pq.top(); pq.pop(); if (t.c > 0 && t.d > D[t.x][t.c]) continue; if (t.c == 0 && t.d > dp[t.x]) continue; for (Edge e : v[t.x]) { if (e.c == t.c) { long long next_d = (t.d - t.p) + ma[t.x][e.c] - e.p; if (dp[e.a] > next_d) { dp[e.a] = next_d; pq.push({e.a, next_d, 0, 0, t.x}); } } if (D[e.a][e.c] > t.d + e.p) { D[e.a][e.c] = t.d + e.p; pq.push({e.a, t.d + e.p, e.c, e.p, t.x}); } if (dp[e.a] > t.d + e.p) { dp[e.a][e.c] = t.d + e.p; pq.push({e.a, t.d + e.p, e.c, e.p. t.x}); } long long next_d = t.d + ma[t.x][e.c] - e.p; if (dp[e.a] > next_d) { dp[e.a] = next_d; pq.push({e.a, next_d, 0, 0, t.x}); } } } long long ans = dp[n]; for (auto d : D[n]) { ans = min(ans, d.second); } if (ans > inf / 2) { cout << -1; return 0; } cout << ans; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:91:24: error: invalid types 'long long int[int]' for array subscript
   91 |                 dp[e.a][e.c] = t.d + e.p;
      |                        ^
Main.cpp:92:52: error: request for member 't' in 'e.Edge::p', which is of non-class type 'long long int'
   92 |                 pq.push({e.a, t.d + e.p, e.c, e.p. t.x});
      |                                                    ^
Main.cpp:92:56: error: no matching function for call to 'std::priority_queue<Node, std::vector<Node>, cmp>::push(<brace-enclosed initializer list>)'
   92 |                 pq.push({e.a, t.d + e.p, e.c, e.p. t.x});
      |                                                        ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = Node; _Sequence = std::vector<Node>; _Compare = cmp; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = Node]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const Node&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = Node; _Sequence = std::vector<Node>; _Compare = cmp; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = Node]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<Node, std::vector<Node>, cmp>::value_type&&' {aka 'Node&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~