# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1121286 | mmdrzada | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1042 ms | 1956 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
vector<int> g[30005];
int f[30005], da[30005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, m, h, k;
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int x, y;
cin >> x >> y;
if (i == 1) h = x;
if (i == 2) k = x;
g[x].push_back(y);
}
for (int i = 0; i < n; i++) f[i] = 1e9;
f[h] = 0;
for (int jj = 0; jj < n; jj++) {
int p, mi = 1e9;
for (int i = 0; i < n; i++) {
if (da[i] == 0 && mi > f[i]) {
mi = f[i];
p = i;
}
}
if (p == k) break;
da[p] = 1;
for (int w : g[p]) {
int l = 0;
for (int j = p - w; j >= 0; j -= w) {
f[j] = min(f[j], f[p] + l + 1);
l++;
}
l = 0;
for (int j = p + w; j < n; j += w) {
f[j] = min(f[j], f[p] + l + 1);
l++;
}
}
}
if (f[k] == 1e9) cout << -1;
else cout << f[k];
}
컴파일 시 표준 에러 (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... |