Submission #299806

#TimeUsernameProblemLanguageResultExecution timeMemory
299806updown1Jakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <string> #include <utility> #include <vector> #include <queue> #include <set> #include <map> #include <unordered_set> using namespace std; bool done[30000] = {}; int n, m, d0, d1, dists[30000] = {}, ans = -1; vector<int> doges[30000]; priority_queue<pair<int, int> > pq; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < m; i++){ int a, b; cin >> a >> b; if (i == 0) d0 = a; if (i == 1) d1 = a; doges[a].push_back(b); } for (int i = 0; i < n; i++){ dists[i] = 30001; } pq.push(make_pair(0, d0)); dists[d0] = 0; while (pq.size() > 0){ int i = pq.top().second; pq.pop(); if (done[i]){ continue; } if (i == d1){ ans = dists[i]; break; } for (int p : doges[i]){ for (int j=loc+p, add = 1; j<N; j+= p, add++) if (dist[loc]+add < dist[j]) { dist[j] = min(dist[j], dist[loc]+add); next1.push(mp(-dist[j], j)); } for (int j=loc-p, add = 1; j>= 0; j-= p, add++) if (dist[loc]+add < dist[j]) { dist[j] = min(dist[j], dist[loc]+add); next1.push(mp(-dist[j], j)); } } done[i] = true; } cout << ans << endl; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:46:24: error: 'loc' was not declared in this scope; did you mean 'clock'?
   46 |             for (int j=loc+p, add = 1; j<N; j+= p, add++) if (dist[loc]+add < dist[j]) {
      |                        ^~~
      |                        clock
skyscraper.cpp:46:42: error: 'N' was not declared in this scope
   46 |             for (int j=loc+p, add = 1; j<N; j+= p, add++) if (dist[loc]+add < dist[j]) {
      |                                          ^
skyscraper.cpp:46:52: error: 'add' was not declared in this scope
   46 |             for (int j=loc+p, add = 1; j<N; j+= p, add++) if (dist[loc]+add < dist[j]) {
      |                                                    ^~~
skyscraper.cpp:46:63: error: 'dist' was not declared in this scope; did you mean 'dists'?
   46 |             for (int j=loc+p, add = 1; j<N; j+= p, add++) if (dist[loc]+add < dist[j]) {
      |                                                               ^~~~
      |                                                               dists
skyscraper.cpp:48:17: error: 'next1' was not declared in this scope
   48 |                 next1.push(mp(-dist[j], j));
      |                 ^~~~~
skyscraper.cpp:48:28: error: 'mp' was not declared in this scope; did you mean 'p'?
   48 |                 next1.push(mp(-dist[j], j));
      |                            ^~
      |                            p
skyscraper.cpp:50:24: error: 'loc' was not declared in this scope; did you mean 'clock'?
   50 |             for (int j=loc-p, add = 1; j>= 0; j-= p, add++) if (dist[loc]+add < dist[j]) {
      |                        ^~~
      |                        clock
skyscraper.cpp:50:54: error: 'add' was not declared in this scope
   50 |             for (int j=loc-p, add = 1; j>= 0; j-= p, add++) if (dist[loc]+add < dist[j]) {
      |                                                      ^~~
skyscraper.cpp:50:65: error: 'dist' was not declared in this scope; did you mean 'dists'?
   50 |             for (int j=loc-p, add = 1; j>= 0; j-= p, add++) if (dist[loc]+add < dist[j]) {
      |                                                                 ^~~~
      |                                                                 dists
skyscraper.cpp:52:17: error: 'next1' was not declared in this scope
   52 |                 next1.push(mp(-dist[j], j));
      |                 ^~~~~
skyscraper.cpp:52:28: error: 'mp' was not declared in this scope; did you mean 'p'?
   52 |                 next1.push(mp(-dist[j], j));
      |                            ^~
      |                            p