Submission #1012269

#TimeUsernameProblemLanguageResultExecution timeMemory
1012269codefoxRobot (JOI21_ho_t4)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #define int long long #define arr array<int, 4> #define pii pair<int, int> vector<vector<arr>> graph; int lim = 1e18; int32_t main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; graph.assign(n, vector<arr>()); vector<map<int, int>> cost(n); vector<map<int, int>> dist(n); vector<map<int, vector<int>>> colour(n); vector<int> mn(n, lim); for (int j = 0; j < m; j++) { int a, b, c, d; cin >> a >> b >> c >> d; a--; b--; c--; graph[a].push_back({b, c, d, 0}); graph[b].push_back({a, c, d, 0}); } for (int i = 0; i < n; i++) { for (arr ele:graph[i]) { cost[i][ele[1]] += ele[2]; dist[ele[0]][ele[1]] = lim; colour[i][ele[1]].push_back(ele[0]); } } priority_queue<arr, vector<arr>, greater<arr>> pq; pq.push({0, 0, 0, 0}); while (pq.size()) { arr a = pq.top(); pq.pop(); int d = a[0]; int c = a[1]; int i = a[2]; int cc = a[3]; if (dist[i][c]<=d) continue; dist[i][c] = d; if (mn[i]==lim) { for (arr ele:graph[i]) { pq.push({d+ele[2], 0, ele[0], ele[2]}); } mn[i] = d; } if (c==0) { for (arr ele:graph[i]) { pq.push({d+cost[i][ele[1]]-ele[2], ele[1], ele[0], ele[2]}); } } else { for (int ele:colour[i][c]) { pq.push({d+cost[i][c]-cc, c, ele, ele[2]}); } } } if (mn[n-1]>=lim) cout << -1; else cout << mn[n-1]; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:88:54: error: invalid types 'long long int[int]' for array subscript
   88 |                 pq.push({d+cost[i][c]-cc, c, ele, ele[2]});
      |                                                      ^
Main.cpp:88:58: error: no matching function for call to 'std::priority_queue<std::array<long long int, 4>, std::vector<std::array<long long int, 4> >, std::greater<std::array<long long int, 4> > >::push(<brace-enclosed initializer list>)'
   88 |                 pq.push({d+cost[i][c]-cc, c, ele, ele[2]});
      |                                                          ^
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 = std::array<long long int, 4>; _Sequence = std::vector<std::array<long long int, 4> >; _Compare = std::greater<std::array<long long int, 4> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<long long int, 4>]'
  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 std::array<long long int, 4>&'}
  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 = std::array<long long int, 4>; _Sequence = std::vector<std::array<long long int, 4> >; _Compare = std::greater<std::array<long long int, 4> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<long long int, 4>]'
  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<std::array<long long int, 4>, std::vector<std::array<long long int, 4> >, std::greater<std::array<long long int, 4> > >::value_type&&' {aka 'std::array<long long int, 4>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~