이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<long long, long long>
vector<int>v[100005], v2[100005];
int dist[100005];
main(){
ios::sync_with_stdio(0);cin.tie(0);
int n,m;
cin >> n >> m;
while(m--){
int a,b,c;
cin >> a >> b >> c;
v[b].push_back(a);
v2[a].push_back(c);
}
priority_queue<pii, vector<pii>, greater<pii> > pq;
pq.push({0,n});
fill(dist, dist + n + 1, 1e18);
dist[n] = 0;
for(int i=1;i<=n;i++)sort(v2[i].begin(), v2[i].end());
while(!pq.empty()){
int x = pq.top().first, y = pq.top().second;
pq.pop();
if(dist[y] < x)continue;
for(auto i : v[y]){
if(v2[i].empty())continue;
if(dist[i] > x + v2[i].back())dist[i] = x + v2[i].back(),pq.push({dist[i],i});
v2[i].pop_back();
}
}
cout <<dist[1];
}
컴파일 시 표준 에러 (stderr) 메시지
ferries.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main(){
| ^~~~
# | 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... |