#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int inf = 1e9;
typedef pair<int,int> ii;
int n, m;
vector<int> rev[N], len[N];
int d[N];
int solve() {
for (int i = 1; i <= n; ++i) d[i] = inf;
priority_queue < ii, vector<ii>, greater<ii> > pq;
pq.push(ii(0, n));
d[n] = 0;
while(!pq.empty()) {
ii top = pq.top(); pq.pop();
int u = top.second, du = top.first;
if (du != d[u]) continue;
if (u == 1) {
return du;
}
for (int v : rev[u]) {
if (d[v] > d[u] + len[v].back()) {
d[v] = d[u] + len[v].back(); len[v].pop_back();
pq.push(ii(d[v], v));
}
}
}
}
int ferries(int N, int M, int *A, int *B, int *C) {
n = N;
m = M;
for (int i = 0; i < M; ++i) {
rev[B[i]].push_back(A[i]);
len[A[i]].push_back(C[i]);
}
for (int i = 1; i <= n; ++i) {
sort(len[i].begin(), len[i].end());
}
return solve();
}
// int main() {
// int tn, tm, ta[10], tb[10], tc[10];
// cin >> tn >> tm;
// for (int i = 0; i < tm; ++i) cin >> ta[i] >> tb[i] >> tc[i];
// cout << ferries(tn, tm, ta, tb, tc);
// }
Compilation message
ferries.cpp: In function 'int solve()':
ferries.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status