# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
124135 | AyaBenSaad | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 468 ms | 49348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 3; //number of skyscrapers
const int M = 3e4 + 4; //number of doges;
const int inf = 1e9;
int n, m, b[M], p[M], ok;
vector <pair <int, int> > adj[M];
int dis[N][N], vis[N];
void Dijkstra (int u) {
priority_queue <pair <long long, int> > q;
vis[u]++;
q.push ({-1, u});
while (q.size()) {
int x = q.top().second;
q.pop();
for (auto e : adj[x]) {
int v = e.first;
long long c = e.second;
if ((!vis[v]) || vis [v] > c + vis[x]){
vis[v] = c + vis[x];
q.push({-vis[v], v});
}
}
}
}
int main () {
scanf ("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d %d", &b[i], &p[i]);
for (int j = 0; j < n; j++) {
if (abs(j-b[i]) % p[i] == 0) {
if (dis[b[i]][j] == 0 || dis[b[i]][j] > abs(j-b[i]) / p[i]) dis[b[i]][j] = abs(j-b[i]) / p[i];
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if ( dis[i][j]) adj[i].push_back({j, dis[i][j]});
}
}
Dijkstra(b[0]);
if (vis[b[1]]) printf("%d\n", vis[b[1]]-1);
else puts("-1");
}
컴파일 시 표준 에러 (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... |