Submission #265026

#TimeUsernameProblemLanguageResultExecution timeMemory
265026jeqchoJakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define f first #define s second int const n=2e3; int dist[n]; vi powin[n]; int N,M; int const m=3e4; int B[m], P[m]; void dij(int x) { dist[x]=0; priority_queue<pii>q; bitset<N> pro; q.push({0,x}); int b,w; vpi adjnow; while(!q.empty()) { int a = q.top().s; q.pop(); if(pro[a])continue; pro[a]=1; adjnow.clear(); trav(pow, powin[a]) { for(int j=0; a+j*pow<N; ++j) { adjnow.pb({a+j*pow, j}); } for(int j=-1; a+j*pow>=0; --j) { adjnow.pb({a+j*pow, -j}); } } trav(e, adjnow) { b=e.f; w=e.s; if(dist[a]+w<dist[b]) { dist[b]=dist[a]+w; q.push({-dist[b],b}); } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>M; F0R(i,M) { cin>>B[i]>>P[i]; powin[B[i]].pb(P[i]); } fill(dist,dist+N,1e9); dij(B[0]); if(dist[B[1]]==1e9)cout<<-1<<'\n'; else cout<<dist[B[1]]<<'\n'; return 0; }

Compilation message (stderr)

skyscraper.cpp: In function 'void dij(int)':
skyscraper.cpp:33:13: error: the value of 'N' is not usable in a constant expression
   33 |     bitset<N> pro;
      |             ^
skyscraper.cpp:25:5: note: 'int N' is not const
   25 | int N,M;
      |     ^
skyscraper.cpp:33:13: note: in template argument for type 'long unsigned int'
   33 |     bitset<N> pro;
      |             ^
skyscraper.cpp:41:17: error: invalid types 'int[int]' for array subscript
   41 |         if(pro[a])continue;
      |                 ^
skyscraper.cpp:42:14: error: invalid types 'int[int]' for array subscript
   42 |         pro[a]=1;
      |              ^