Submission #355227

# Submission time Handle Problem Language Result Execution time Memory
355227 2021-01-22T10:27:51 Z Pety Jakarta Skyscrapers (APIO15_skyscraper) C++14
Compilation error
0 ms 0 KB
#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>, vector<pair<int, int>>, greater<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});
  }
  for (int i = 0; i < n; i++)
    dsit[i] = 1e9;
  dist[q.top().second] = 0;
  while (!q.empty()) {
    auto x = q.top();
    q.pop();
    if (dist[x.second] != x.first)
      continue;
    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 >= 0; 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: In function 'int main()':
skyscraper.cpp:23:5: error: 'dsit' was not declared in this scope; did you mean 'dist'?
   23 |     dsit[i] = 1e9;
      |     ^~~~
      |     dist