# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45443 | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1088 ms | 33460 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <vector>
#include <queue>
#define INF 1000000007
int B[30005], P[30005];
std::vector<std::pair<int, int> > AdjList[30005];
int abs(int a)
{
return (a < 0)?-a:a;
}
int Min[30005];
typedef struct node node;
struct node
{
int u, w;
};
bool operator<(node a, node b)
{
return (a.w > b.w);
}
std::priority_queue<node> Q;
int main()
{
int N, M;
scanf("%d %d", &N, &M);
int i, j;
for (i = 0; i < M; i++)
scanf("%d %d", &B[i], &P[i]);
for (i = 0; i < M; i++)
{
for (j = 0; j < M; j++)
{
if (i == j) continue;
if (abs(B[i] - B[j])%P[i] == 0)
AdjList[i].push_back({j, abs(B[i] - B[j])/P[i]});
}
Min[i] = INF;
}
Min[0] = 0;
Q.push({0, 0});
node p;
int v, w, s;
while (!Q.empty())
{
do
{
p = Q.top();
Q.pop();
} while (Min[p.u] < p.w);
if (p.u == 1)
{
printf("%d", p.w);
return 0;
}
s = AdjList[p.u].size();
for (i = 0; i < s; i++)
{
v = AdjList[p.u][i].first;
w = AdjList[p.u][i].second;
if (p.w + w < Min[v])
{
Min[v] = p.w + w;
Q.push({v, Min[v]});
}
}
}
printf("-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... |