# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
400785 | BERNARB01 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 855 ms | 64068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
const long long inf = (long long) 8e18L;
long long g[N][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
g[i][j] = inf;
}
}
int target, start;
for (int i = 0; i < m; i++) {
int b, p;
cin >> b >> p;
if (i == 0) {
start = b;
}
if (i == 1) {
target = b;
}
for (int j = 0; j < n; j++) {
int d = abs(b - j);
if (d % p == 0) {
g[b][j] = min(g[b][j], (long long) d / p);
}
}
}
vector<long long> dist(n, inf);
priority_queue<pair<long long, int>> s;
dist[start] = 0;
s.emplace(0, start);
while (!s.empty()) {
long long exp = -s.top().first;
int u = s.top().second;
s.pop();
if (exp != dist[u]) {
continue;
}
for (int v = 0; v < n; v++) {
if (dist[u] + g[u][v] < dist[v]) {
dist[v] = dist[u] + g[u][v];
s.emplace(-dist[v], v);
}
}
}
cout << (dist[target] >= inf ? -1 : dist[target]) << '\n';
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... |