# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
272741 | toonewbie | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 202 ms | 8312 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int MAX_N = 30000, RTN = 200;
int n, m, dist[MAX_N], s, e;
bool ck[MAX_N][RTN], fvis[MAX_N];
struct st{
int b, p, w;
st(int _b, int _p, int _w)
:b(_b), p(_p), w(_w){}
};
vector<int> adj[MAX_N];
queue<st> q;
int main(){
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++){
int a, b;
scanf("%d %d", &a, &b);
adj[a].push_back(b);
if (i == 0) s = a;
if (i == 1) e = a;
}
dist[e] = -1;
q.push(st(s, 0, 0));
while (!q.empty()){
st h = q.front();
q.pop();
if (h.b < 0 || h.b >= n) continue;
if (abs(h.p) < RTN){
if (ck[h.b][abs(h.p)]) continue;
ck[h.b][abs(h.p)] = true;
}
if (!fvis[h.b]){
fvis[h.b] = true;
dist[h.b] = h.w;
for (auto t : adj[h.b]){
q.push(st(h.b + t, t, h.w + 1));
q.push(st(h.b - t, -t, h.w + 1));
}
}
q.push(st(h.b + h.p, h.p, h.w + 1));
}
printf("%d", dist[e]);
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... |