Submission #1110692

#TimeUsernameProblemLanguageResultExecution timeMemory
1110692haru09Jakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second const int ar = 5e4 + 5; const ll mod = 1e9 + 7; int n, m; int sqr; int b[ar]; int p[ar]; int dp[ar][226]; vector<int> ad[ar]; struct seg { int dis, i, p; }; bool operator>(seg a, seg b) { return a.dis > b.dis; } queue<seg, vector<seg>, greater<seg> > pq; int ans = 1e9; void dijkstra() { memset(dp, 0x3f, sizeof dp); pq.push({0, b[0], 0}); dp[b[0]][0] = 0; while(pq.size()) { seg top = pq.top(); pq.pop(); int dis = top.dis; int i = top.i; int pk = top.p; if (dp[i][pk] < dis) continue; if (i == b[1]) ans = min(ans, dis); if (pk == 0) { for (auto x : ad[i]) { if (p[x] <= sqr) { if (dp[i][p[x]] > dis) { dp[i][p[x]] = dis; pq.push({dis, i, p[x]}); } } else { int cnt = 0; for (int j = i; j < n; j += p[x]) { if (dp[j][0] > dis + cnt) { dp[j][0] = dis + cnt; pq.push({dp[j][0], j, 0}); } cnt++; } cnt = 0; for (int j = i; j >= 0; j -= p[x]) { if (dp[j][0] > dis + cnt) { dp[j][0] = dis + cnt; pq.push({dp[j][0], j, 0}); } cnt++; } } } } else { if (i + pk < n && dp[i + pk][pk] > dis + 1) { dp[i + pk][pk] = dis + 1; pq.push({dp[i + pk][pk], i + pk, pk}); } if (i - pk >= 0 && dp[i - pk][pk] > dis + 1) { dp[i - pk][pk] = dis + 1; pq.push({dp[i - pk][pk], i - pk, pk}); } if (dp[i][0] > dis) { dp[i][0] = dis; pq.push({dp[i][0], i, 0}); } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { cin >> b[i] >> p[i]; ad[b[i]].push_back(i); } sqr = 225; dijkstra(); if (ans == 1e9) ans = -1; cout << ans; }

Compilation message (stderr)

skyscraper.cpp:24:38: error: wrong number of template arguments (3, should be at least 1)
   24 | queue<seg, vector<seg>, greater<seg> > pq;
      |                                      ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:96:11: note: provided for 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
skyscraper.cpp: In function 'void dijkstra()':
skyscraper.cpp:29:8: error: request for member 'push' in 'pq', which is of non-class type 'int'
   29 |     pq.push({0, b[0], 0});
      |        ^~~~
skyscraper.cpp:31:14: error: request for member 'size' in 'pq', which is of non-class type 'int'
   31 |     while(pq.size())
      |              ^~~~
skyscraper.cpp:33:22: error: request for member 'top' in 'pq', which is of non-class type 'int'
   33 |         seg top = pq.top();
      |                      ^~~
skyscraper.cpp:34:12: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   34 |         pq.pop();
      |            ^~~
skyscraper.cpp:49:28: error: request for member 'push' in 'pq', which is of non-class type 'int'
   49 |                         pq.push({dis, i, p[x]});
      |                            ^~~~
skyscraper.cpp:60:32: error: request for member 'push' in 'pq', which is of non-class type 'int'
   60 |                             pq.push({dp[j][0], j, 0});
      |                                ^~~~
skyscraper.cpp:70:32: error: request for member 'push' in 'pq', which is of non-class type 'int'
   70 |                             pq.push({dp[j][0], j, 0});
      |                                ^~~~
skyscraper.cpp:82:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
   82 |                 pq.push({dp[i + pk][pk], i + pk, pk});
      |                    ^~~~
skyscraper.cpp:87:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
   87 |                 pq.push({dp[i - pk][pk], i - pk, pk});
      |                    ^~~~
skyscraper.cpp:92:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
   92 |                 pq.push({dp[i][0], i, 0});
      |                    ^~~~