| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 761771 | KN200711 | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 252 ms | 112196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
# define fi first
# define se second
# define ll long long
using namespace std;
const int sq = 200;
vector<int> dg[30001];
bitset<30001> jp[30001];
int st, js, ed;
int rc[30001];
bool vis[30001];
ll ch(int a, int b) {
return (1ll * 1e9 * 1ll * a) + (1ll * b);
}
int main() {
int N, M;
scanf("%d %d", &N, &M);
for(int i=0;i<N;i++) rc[i] = 1e9;
for(int i=0;i<M;i++) {
int a, b;
scanf("%d %d", &a, &b);
if(i == 0) {
st = a;
js = b;
} else if(i == 1) ed = a;
else dg[a].push_back(b);
}
queue< pair<pair<int, int>, int> > BFS;
BFS.push(make_pair(make_pair(st, 0), js));
while(BFS.size()) {
int a, b, c;
a = BFS.front().fi.fi;
b = BFS.front().fi.se;
c = BFS.front().se;
// cout<<a<<" "<<b<<" "<
BFS.pop();
rc[a] = min(rc[a], b);
if(a == ed) break;
if(a - c >= 0 && jp[a-c][c] == 0) {
BFS.push(make_pair(make_pair(a - c, b + 1), c));
jp[a-c][c] = 1;
}
if(a + c < N && jp[a+c][c] == 0) {
BFS.push(make_pair(make_pair(a+c, b + 1), c));
jp[a+c][c] = 1;
}
if(vis[a]) continue;
vis[a] = 1;
for(int k=0;k<dg[a].size();k++) {
c = dg[a][k];
if(a - c >= 0 && jp[a-c][c] == 0) {
BFS.push(make_pair(make_pair(a - c, b + 1), c));
jp[a-c][c] = 1;
}
if(a + c < N && jp[a+c][c] == 0) {
BFS.push(make_pair(make_pair(a+c, b + 1), c));
jp[a+c][c] = 1;
}
}
}
if(rc[ed] == 1e9) rc[ed] = -1;
printf("%d\n", rc[ed]);
}컴파일 시 표준 에러 (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... | ||||
