Submission #925548

#TimeUsernameProblemLanguageResultExecution timeMemory
925548panJakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define f first #define s second #define input(x) scanf("%d", &x); #define print(x, y) printf("%d%c", x, y); typedef int ll; typedef pair<ll, ll> pi; ll const INF = 1e9; vector<ll> adj[30005]; ll where[30005]; int main() { ll n, m, b, p; input(n); input(m); vector<ll> adj[n]; ll where[m]; vector<ll> dist(n, INF); for (ll i=0; i<m; ++i) { input(b); input(p); adj[b].pb(p); where[i] = b; } set<pi> s; dist[where[0]] = 0; s.insert(mp(0, where[0])); while (!s.empty()) { ll c= s.begin()->s; s.erase(s.begin()); for (ll u: adj[c]) { ll jump = 0; for (ll x=c+u; x<n; x+=u) { jump++; if (dist[x]>dist[c]+jump) { if (dist[x]!=INF) s.erase(mp(dist[x], x)); dist[x] = dist[c]+jump; s.insert(mp(dist[x], x)); } } jump = 0; for (ll x=c-u; x>=0; x-=u) { jump++; if (dist[x]>dist[c]+jump) { if (dist[x]!=INF) s.erase(mp(dist[x], x)); dist[x] = dist[c]+jump; s.insert(mp(dist[x], x)); } } } } if (dist[where[1]]==INF) {print(-1, '\n');} else {print(dist[where[1]], '\n');} return 0; }

Compilation message (stderr)

skyscraper.cpp:7:9: error: 'pair' does not name a type
    7 | typedef pair<ll, ll> pi;
      |         ^~~~
skyscraper.cpp:10:1: error: 'vector' does not name a type
   10 | vector<ll> adj[30005];
      | ^~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:16:2: error: 'vector' was not declared in this scope
   16 |  vector<ll> adj[n];
      |  ^~~~~~
skyscraper.cpp:16:2: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from skyscraper.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from skyscraper.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
skyscraper.cpp:16:11: error: expected primary-expression before '>' token
   16 |  vector<ll> adj[n];
      |           ^
skyscraper.cpp:16:13: error: 'adj' was not declared in this scope
   16 |  vector<ll> adj[n];
      |             ^~~
skyscraper.cpp:18:11: error: expected primary-expression before '>' token
   18 |  vector<ll> dist(n, INF);
      |           ^
skyscraper.cpp:18:13: error: 'dist' was not declared in this scope
   18 |  vector<ll> dist(n, INF);
      |             ^~~~
skyscraper.cpp:25:2: error: 'set' was not declared in this scope
   25 |  set<pi> s;
      |  ^~~
skyscraper.cpp:25:2: note: suggested alternatives:
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from skyscraper.cpp:1:
/usr/include/c++/10/bits/stl_set.h:94:11: note:   'std::set'
   94 |     class set
      |           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from skyscraper.cpp:1:
/usr/include/c++/10/set:78:13: note:   'std::pmr::set'
   78 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
skyscraper.cpp:25:6: error: 'pi' was not declared in this scope; did you mean 'p'?
   25 |  set<pi> s;
      |      ^~
      |      p
skyscraper.cpp:3:11: error: 'second' was not declared in this scope
    3 | #define s second
      |           ^~~~~~
skyscraper.cpp:25:10: note: in expansion of macro 's'
   25 |  set<pi> s;
      |          ^
skyscraper.cpp:27:11: error: 'mp' was not declared in this scope; did you mean 'p'?
   27 |  s.insert(mp(0, where[0]));
      |           ^~
      |           p
skyscraper.cpp:4:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:15:2: note: in expansion of macro 'input'
   15 |  input(n); input(m);
      |  ^~~~~
skyscraper.cpp:4:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:15:12: note: in expansion of macro 'input'
   15 |  input(n); input(m);
      |            ^~~~~
skyscraper.cpp:4:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:21:3: note: in expansion of macro 'input'
   21 |   input(b); input(p);
      |   ^~~~~
skyscraper.cpp:4:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:21:13: note: in expansion of macro 'input'
   21 |   input(b); input(p);
      |             ^~~~~