# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45446 | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 339 ms | 32636 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <vector>
#include <set>
#include <algorithm>
#define INF 1000000007
int B[30005], P[30005];
int AdjList[2005][2005];
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 || (a.w == b.w && a.u < b.u));
}
std::set<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 < N; i++)
for (j = 0; j < N; j++)
AdjList[i][j] = INF;
for (i = 0; i < M; i++)
{
for (j = 0; j < N; j++)
{
if (B[i] == j) continue;
if (abs(B[i] - j)%P[i] == 0)
AdjList[B[i]][j] = std::min(AdjList[B[i]][j], abs(B[i] - j)/P[i]);
}
}
for (i = 0; i < N; i++)
Min[i] = INF;
Min[B[0]] = 0;
Q.insert({B[0], 0});
node p;
int v, w, s;
while (!Q.empty())
{
p = *Q.begin();
Q.erase(Q.begin());
// printf("pop %d %d\n", p.u, p.w);
if (p.u == B[1])
{
printf("%d", p.w);
return 0;
}
for (i = 0; i < N; i++)
{
w = AdjList[p.u][i];
if (p.w + w < Min[i])
{
if (Min[i] != INF)
Q.erase({i, Min[i]});
Min[i] = p.w + w;
Q.insert({i, Min[i]});
}
}
}
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... |