# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
294990 | thebes | 페리들 (NOI13_ferries) | C++14 | 364 ms | 17832 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MN = 1e5+5;
int N, M, i, x, y, W, dist[MN];
vector<int> adj[MN], w[MN];
typedef pair<int,int> pii;
struct pq{bool operator()(const pii&i,const pii&j){return i.second>j.second;}};
priority_queue<pii,vector<pii>,pq> q;
int main(){
for(scanf("%d%d",&N,&M),i=1;i<=M;i++){
scanf("%d%d%d",&x,&y,&W);
adj[y].push_back(x);
w[x].push_back(W);
}
for(i=1;i<=N;i++) sort(w[i].begin(),w[i].end(),[](int i,int j){return i<j;});
memset(dist,-1,sizeof(dist));
q.push({N,0});
while(q.size()){
auto v=q.top(); q.pop();
if(dist[v.first]!=-1) continue;
else dist[v.first]=v.second;
for(auto e : adj[v.first]){
W = w[e].back();
if(dist[e]==-1){
w[e].pop_back();
q.push({e, W+v.second});
}
}
}
printf("%d\n",dist[1]);
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... |