# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38108 | 2018-01-01T07:09:47 Z | nibnalin | Ferries (NOI13_ferries) | C++14 | 766 ms | 26996 KB |
#include <iostream> #include <cstdio> #include <vector> #include <set> using namespace std; const int maxn = int(1e5)+5, inf = int(2e9)+5; int D[maxn]; multiset<int> into[maxn]; vector<int> graph[maxn]; int main(void) { int n, m, a, b, c; scanf("%d%d", &n, &m); for(int i = 0;i < n;i++) D[i] = inf; for(int i = 0;i < m;i++) { scanf("%d%d%d", &a, &b, &c); a--, b--; graph[b].push_back(a); into[a].insert(c); } set<pair<int, int>> Q; D[n-1] = 0; Q.insert({D[n-1], n-1}); while(!Q.empty()) { pair<int, int> top = *Q.begin(); Q.erase(Q.begin()); if(D[top.second] < top.first) continue; //cout << top.first << " " << top.second << "\n"; for(auto it: graph[top.second]) { //if(into[it].empty()) continue; int w = *into[it].rbegin(); into[it].erase(into[it].find(w)); if(D[it] > D[top.second]+w) { D[it] = D[top.second]+w; if(D[it] != inf) Q.erase({D[it], it}); Q.insert({D[it], it}); } } } printf("%d\n", D[0]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 9440 KB | Output is correct |
2 | Correct | 3 ms | 9572 KB | Output is correct |
3 | Correct | 16 ms | 10768 KB | Output is correct |
4 | Correct | 333 ms | 22504 KB | Output is correct |
5 | Correct | 383 ms | 22504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 9440 KB | Output is correct |
2 | Correct | 3 ms | 9572 KB | Output is correct |
3 | Correct | 19 ms | 10632 KB | Output is correct |
4 | Correct | 133 ms | 15904 KB | Output is correct |
5 | Correct | 246 ms | 17944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 11156 KB | Output is correct |
2 | Correct | 33 ms | 11156 KB | Output is correct |
3 | Correct | 599 ms | 26996 KB | Output is correct |
4 | Correct | 726 ms | 26864 KB | Output is correct |
5 | Correct | 716 ms | 26864 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 576 ms | 26996 KB | Output is correct |
2 | Correct | 569 ms | 26996 KB | Output is correct |
3 | Correct | 759 ms | 26996 KB | Output is correct |
4 | Correct | 766 ms | 26996 KB | Output is correct |
5 | Correct | 683 ms | 26996 KB | Output is correct |