# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260787 | T0p_ | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 702 ms | 6004 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
struct DJK
{
int node;
long long weight;
bool operator < (const DJK & o) const
{
return weight > o.weight;
}
};
vector<int> B[30003];
long long dis[30003];
bool visit[30003];
priority_queue<DJK> djk;
int main()
{
int n, m, s, e;
scanf(" %d %d",&n,&m);
for(int i=1, b, p ; i<=m ; i++)
{
scanf(" %d %d",&b,&p);
b++;
B[b].push_back(p);
if(i == 1) s = b;
if(i == 2) e = b;
}
for(int i=1 ; i<=n ; i++)
dis[i] = 1e15;
dis[s] = 0;
djk.push({s, 0});
while(!djk.empty())
{
int nown = djk.top().node;
long long noww = djk.top().weight;
djk.pop();
if(visit[nown]) continue ;
visit[nown] = true;
if(nown == e)
{
printf("%lld\n",noww);
return 0;
}
for(auto x : B[nown])
{
//left
for(int i=1 ; nown - x*i >= 1 ; i++)
if(dis[nown - x*i] > dis[nown] + i)
{
dis[nown - x*i] = dis[nown]+i;
djk.push({nown - x*i, dis[nown - x*i]});
}
//right
for(int i=1 ; nown + x*i <= n ; i++)
if(dis[nown + x*i] > dis[nown] + i)
{
dis[nown + x*i] = dis[nown]+i;
djk.push({nown + x*i, dis[nown + x*i]});
}
}
}
printf("-1\n");
return 0;
}
컴파일 시 표준 에러 (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... |