# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
601328 |
2022-07-21T17:41:07 Z |
narvalo |
Ferries (NOI13_ferries) |
C++17 |
|
110 ms |
15328 KB |
#include <bits/stdc++.h>
using namespace std;
int ferries(int n , int m , vector<int> a , vector<int> b , vector<int> c) {
vector<vector<pair<int , int>>> adj(n);
for (int i = 0 ; i < m ; i++) {
a[i] -= 1 , b[i] -= 1;
adj[a[i]].emplace_back(b[i] , c[i]);
}
vector<int> mx(n);
for (int i = 0 ; i < n ; i++) {
for (auto x : adj[i]) {
mx[i] = max(mx[i] , x.second);
}
}
const int INF = (int)1e9;
vector<int> dest(n , INF);
#define pi pair<int , int>
priority_queue<pi , vector<pi> , greater<pi>> pq;
dest[0] = 0;
pq.emplace(dest[0] , 0);
while (!pq.empty()) {
auto X = pq.top();
pq.pop();
if (X.first != dest[X.second]) continue;
for (auto x : adj[X.second]) {
if (dest[x.first] > X.first + mx[X.second]) {
dest[x.first] = X.first + mx[X.second];
pq.emplace(dest[x.first] , x.first);
}
}
}
int res = dest[n - 1];
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n , m;
cin >> n >> m;
vector<int> a(m) , b(m) , c(m);
for (int i = 0 ; i < m ; i += 1) {
cin >> a[i] >> b[i] >> c[i];
}
cout << ferries(n , m , a , b , c) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1820 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
110 ms |
15328 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |