# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45448 | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 555 ms | 121124 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define INF 1000000007
int B[30005], P[30005];
int abs(int a)
{
return (a < 0)?-a:a;
}
long long Vis[30005][505];
typedef struct node node;
struct node
{
int u, j, t;
};
std::vector<int> J[30005];
std::queue<node> Q;
int main()
{
int N, M;
scanf("%d %d", &N, &M);
int i;
node p;
for (i = 0; i < M; i++)
{
scanf("%d %d", &B[i], &P[i]);
if (i == 0)
p = {B[i], P[i], 0};
else
J[B[i]].push_back(P[i]);
}
Vis[B[0]][P[i]/60] |= (1LL << (P[i]%60));
Q.push(p);
int w;
while (!Q.empty())
{
p = Q.front();
Q.pop();
// printf("pop %d %d %d\n", p.u, p.j, p.t);
if (p.u == B[1])
{
printf("%d", p.t);
return 0;
}
if (p.u + p.j < N && (Vis[p.u + p.j][p.j/60]&(1LL << (p.j%60))) == 0)
{
Vis[p.u + p.j][p.j/60] |= (1LL << (p.j%60));
Q.push({p.u + p.j, p.j, p.t + 1});
}
if (p.u - p.j >= 0 && (Vis[p.u - p.j][p.j/60]&(1LL << (p.j%60))) == 0)
{
Vis[p.u - p.j][p.j/60] |= (1LL << (p.j%60));
Q.push({p.u - p.j, p.j, p.t + 1});
}
for (i = 0; i < J[p.u].size(); i++)
{
w = J[p.u][i];
if (p.u + w < N && (Vis[p.u + w][w/60]&(1LL << (w%60))) == 0)
{
Vis[p.u + w][w/60] |= (1LL << (w%60));
Q.push({p.u + w, w, p.t + 1});
}
if (p.u - w >= 0 && (Vis[p.u - w][w/60]&(1LL << (w%60))) == 0)
{
Vis[p.u - w][w/60] |= (1LL << (w%60));
Q.push({p.u - w, w, p.t + 1});
}
}
}
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... |