제출 #253925

#제출 시각아이디문제언어결과실행 시간메모리
253925ChrisTJakarta Skyscrapers (APIO15_skyscraper)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define hsh(x,y) (x)<<15|(y) using namespace std; const int MN = 30005; int b[MN], p[MN]; pair<int,int> dq[11000000]; bitset<1000000000> vis; vector<int> st[MN]; int main () { int n,m; scanf ("%d %d",&n,&m); for (int i = 0; i < m; i++) { scanf ("%d %d",&b[i],&p[i]); st[b[i]].push_back(i); } int l = n, r = l + 1; dq[l] = {hsh(b[0],p[0]),0}; while (l < r) { int cur = dq[l].first>>15, power = dq[l].first & 0x7FFF, dist = dq[l].second; ++l; if (cur == b[1]) return !printf ("%d\n",dist); for (int i : st[cur]) if (!vis[hsh(cur,p[i])]) { vis[hsh(cur,p[i])] = 1; dq[--l] = {hsh(cur,p[i]),dist}; } st[cur].clear(); if (cur >= power && !vis[hsh(cur-power,power)]) { vis[hsh(cur-power,power)] = 1; dq[r++] = {hsh(cur-power,power),dist+1}; } if (cur + power < n && !vis[hsh(cur+power,power)]) { vis[hsh(cur+power,power)] = 1; dq[r++] = {hsh(cur+power,power),dist+1}; } } printf ("-1\n"); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Compilation timeout while compiling skyscraper