# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
52634 | evpipis | Jakarta Skyscrapers (APIO15_skyscraper) | C++11 | 1083 ms | 71076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
const int len = 30005, inf = 1e9;
int po[len], pos[len], vis[len];
vector<int> vec[len];
map<int, int> mymap[len];
deque<pair<int, ii> > deq;
int main(){
int n, m;
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++)
scanf("%d %d", &pos[i], &po[i]);
for (int i = 0; i < m; i++)
vec[pos[i]].pb(po[i]);
int ans = -1;
deq.pb(mp(0, mp(pos[0], po[0])));
while (!deq.empty()){
pair<int, ii> top = deq.front();
deq.pop_front();
int d = top.fi, b = top.se.fi, p = top.se.se;
if (b == pos[1]){
ans = d;
break;
}
if (mymap[b].count(p)) continue;
mymap[b][p] = d;
if (b+p < n)
deq.pb(mp(d+1, mp(b+p, p)));
if (b-p >= 0)
deq.pb(mp(d+1, mp(b-p, p)));
if (vis[b]) continue;
vis[b] = 1;
for (int j = 0; j < vec[b].size(); j++)
deq.push_front(mp(d, mp(b, vec[b][j])));
}
printf("%d\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |