# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153066 | songc | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 1082 ms | 70828 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
int N, M, S, E;
set<int> chk[30303];
vector<int> V[30303];
int D[30303];
priority_queue<pii, vector<pii>, greater<pii>> PQ;
int main(){
scanf("%d %d", &N, &M);
for (int i=1; i<=M; i++){
int x, y;
scanf("%d %d", &x, &y);
if (i == 1) S = x;
if (i == 2) E = x;
V[x].push_back(y);
}
memset(D, -1, sizeof D);
PQ.push(pii(0, S));
while (!PQ.empty()){
int x, d;
tie(d,x) = PQ.top();
PQ.pop();
if (D[x] != -1) continue;
D[x] = d;
for (int v : V[x]){
for (int i=1; x-v*i>=0; i++){
if (chk[x-v*i].find(v) != chk[x-v*i].end()) break;
chk[x-v*i].insert(v);
PQ.push(pii(d+i, x-v*i));
}
for (int i=1; x+v*i<N; i++){
if (chk[x+v*i].find(v) != chk[x+v*i].end()) break;
chk[x+v*i].insert(v);
PQ.push(pii(d+i, x+v*i));
}
}
}
printf("%d\n", D[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... |