| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 417784 | DEQK | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1 ms | 972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e4 + 10;
vector<vector<pair<int, int>>> g(N);
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, m; cin >> n >> m;
int f, s;
for(short i = 0; i < m; i++) {
int x, y; cin >> x >> y;
if(i == 0) f = x;
if(i == 1) s = x;
if(y == 0) continue;
for(int j = x + y; j < n; j += y) {
g[x].push_back({j, (j - x) / y});
}
for(int j = x - y; j >= 0; j -= y) {
g[x].push_back({j, (x - j) / y});
}
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> c;
vector<int> d(n, 2e9);
d[f] = 0;
c.push({0, f});
while(!c.empty()) {
ll w; int u;
tie(w, u) = c.top();
c.pop();
if(d[u] != w) continue;
for(pair<ll, int> to : g[u]) {
if(d[to.first] > d[u] + to.second) {
d[to.first] = d[u] + to.second;
c.push({d[to.first], to.first});
}
}
}
cout << (d[s] == 1e15 ? -1 : d[s]);
}컴파일 시 표준 에러 (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... | ||||
