# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82417 | 2018-10-30T13:45:11 Z | farukkastamonuda | Ferries (NOI13_ferries) | C++14 | 323 ms | 20360 KB |
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000009 #define md 1000000007 #define li 100005 #define mp make_pair #define pb push_back #define mid (start+end)/2 using namespace std; int n, m, x, y, z, d[li]; vector<int> v[li], t[li]; priority_queue< pair<int, int> > q; void bfs(){ for(int i = 1; i < n; i ++) d[i] = inf; q.push(mp(0, n)); while(! q.empty()){ pair<int, int> temp = q.top(); q.pop(); int cst = - temp.fi; int seh = temp.se; if(d[seh] != cst) continue; if(seh == 1){ printf("%d\n", cst); exit(0); } for(int i = 0; i < (int)v[seh].size(); i ++){ int ata = v[seh][i]; if( ( int ) t[ata].size() > 0){ int knr = t[ata].back(); t[ata].pop_back(); if(d[ata] > d[seh] + knr){ d[ata] = d[seh] + knr; q.push(mp(- d[ata], ata)); } } } } } int main(){ scanf("%d %d", &n, &m); for(int i = 1; i <= m; i ++){ scanf("%d %d %d", &x, &y, &z); v[y].pb(x); t[x].pb(z); } for(int i = 1;i <= n; i ++){ sort(t[i].begin(), t[i].end()); } bfs(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5248 KB | Output is correct |
3 | Correct | 26 ms | 6364 KB | Output is correct |
4 | Correct | 159 ms | 16116 KB | Output is correct |
5 | Correct | 161 ms | 16120 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 16120 KB | Output is correct |
2 | Correct | 7 ms | 16120 KB | Output is correct |
3 | Correct | 16 ms | 16120 KB | Output is correct |
4 | Correct | 65 ms | 16120 KB | Output is correct |
5 | Correct | 91 ms | 16120 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 16120 KB | Output is correct |
2 | Correct | 23 ms | 16120 KB | Output is correct |
3 | Correct | 291 ms | 16120 KB | Output is correct |
4 | Correct | 323 ms | 16120 KB | Output is correct |
5 | Correct | 297 ms | 16120 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 294 ms | 16120 KB | Output is correct |
2 | Correct | 285 ms | 16120 KB | Output is correct |
3 | Correct | 271 ms | 16120 KB | Output is correct |
4 | Correct | 320 ms | 16120 KB | Output is correct |
5 | Correct | 297 ms | 20360 KB | Output is correct |