# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
81828 | antimirage | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 4 ms | 2208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
using namespace std;
const int N = 3e4 + 5;
int n, m, en, pos, p, d[N], st;
set <int> vec[N];
priority_queue < pair <int, int> > q;
int main()
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
scanf("%d%d", &pos, &p);
vec[pos].insert(p);
if (i == 1)
st = pos;
if (i == 2)
en = pos;
}
memset(d, 0x3f3f3f3f, sizeof(d));
d[st] = 0;
q.push( mk( 0, st ) );
while (!q.empty())
{
int v = q.top().sc, len = -q.top().fr;
q.pop();
if (d[v] < len) continue;
for (auto to : vec[v])
{
for (int i = v % to; i < n; i += to)
{
if (d[i] > d[v] + abs(v - i) / to)
{
d[i] = d[v] + abs(v - i) / to;
q.push( mk( -d[i], i ) );
}
}
}
}
cout << d[en] << endl;
}
컴파일 시 표준 에러 (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... |