Submission #355208

# Submission time Handle Problem Language Result Execution time Memory
355208 2021-01-22T10:15:46 Z Pety Jakarta Skyscrapers (APIO15_skyscraper) C++14
Compilation error
0 ms 0 KB
v#include <bits/stdc++.h>

using namespace std;

int n, m, dist[30002], poz;
set<int>s[30002];
bool viz[30002];

int main()
{
  cin >> n >> m;
  priority_queue<pair<int, int> > q;
  for (int i = 0; i < m; i++) {
    int b, p;
    cin >> b >> p;
    if (i == 1)
      poz = b;
    s[b].insert(p);
    if (i == 0)
      q.push({0, b});
  }
  fill(dist + 1, dist + n + 1, 1e9);
  dist[q.top().second] = 0;
  while (!q.empty()) {
    auto x = q.top();
    q.pop();
    if (x.second == poz)
      break;
    for (auto it : s[x.second]) {
      for (int i = x.second; i <= n; i += it) {
        if (dist[i] > dist[x.second] + (i - x.second) / it) {
          dist[i] = dist[x.second] + (i - x.second) / it;
          q.push({dist[i], i});
        }
      }
      for (int i = x.second; i >= 1; i -= it) {
        if (dist[i] > dist[x.second] + (x.second) - i / it) {
          dist[i] = dist[x.second] + (x.second - i) / it;
          q.push({dist[i], i});
        }
      }
    }
  }
  if (dist[poz] == 1e9)
    dist[poz] = -1;
  cout << dist[poz];
  return 0;
}

Compilation message

skyscraper.cpp:1:2: error: stray '#' in program
    1 | v#include <bits/stdc++.h>
      |  ^
skyscraper.cpp:1:1: error: 'v' does not name a type
    1 | v#include <bits/stdc++.h>
      | ^
skyscraper.cpp:6:1: error: 'set' does not name a type
    6 | set<int>s[30002];
      | ^~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:11:3: error: 'cin' was not declared in this scope
   11 |   cin >> n >> m;
      |   ^~~
skyscraper.cpp:12:3: error: 'priority_queue' was not declared in this scope
   12 |   priority_queue<pair<int, int> > q;
      |   ^~~~~~~~~~~~~~
skyscraper.cpp:12:18: error: 'pair' was not declared in this scope
   12 |   priority_queue<pair<int, int> > q;
      |                  ^~~~
skyscraper.cpp:12:23: error: expected primary-expression before 'int'
   12 |   priority_queue<pair<int, int> > q;
      |                       ^~~
skyscraper.cpp:18:5: error: 's' was not declared in this scope
   18 |     s[b].insert(p);
      |     ^
skyscraper.cpp:20:7: error: 'q' was not declared in this scope
   20 |       q.push({0, b});
      |       ^
skyscraper.cpp:22:3: error: 'fill' was not declared in this scope
   22 |   fill(dist + 1, dist + n + 1, 1e9);
      |   ^~~~
skyscraper.cpp:23:8: error: 'q' was not declared in this scope
   23 |   dist[q.top().second] = 0;
      |        ^
skyscraper.cpp:29:20: error: 's' was not declared in this scope
   29 |     for (auto it : s[x.second]) {
      |                    ^
skyscraper.cpp:46:3: error: 'cout' was not declared in this scope
   46 |   cout << dist[poz];
      |   ^~~~