# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294990 | 2020-09-09T11:42:46 Z | thebes | Ferries (NOI13_ferries) | C++14 | 364 ms | 17832 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 1e5+5; int N, M, i, x, y, W, dist[MN]; vector<int> adj[MN], w[MN]; typedef pair<int,int> pii; struct pq{bool operator()(const pii&i,const pii&j){return i.second>j.second;}}; priority_queue<pii,vector<pii>,pq> q; int main(){ for(scanf("%d%d",&N,&M),i=1;i<=M;i++){ scanf("%d%d%d",&x,&y,&W); adj[y].push_back(x); w[x].push_back(W); } for(i=1;i<=N;i++) sort(w[i].begin(),w[i].end(),[](int i,int j){return i<j;}); memset(dist,-1,sizeof(dist)); q.push({N,0}); while(q.size()){ auto v=q.top(); q.pop(); if(dist[v.first]!=-1) continue; else dist[v.first]=v.second; for(auto e : adj[v.first]){ W = w[e].back(); if(dist[e]==-1){ w[e].pop_back(); q.push({e, W+v.second}); } } } printf("%d\n",dist[1]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5376 KB | Output is correct |
2 | Correct | 9 ms | 5504 KB | Output is correct |
3 | Correct | 24 ms | 6656 KB | Output is correct |
4 | Correct | 193 ms | 16608 KB | Output is correct |
5 | Correct | 143 ms | 16612 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5376 KB | Output is correct |
2 | Correct | 7 ms | 5504 KB | Output is correct |
3 | Correct | 15 ms | 6528 KB | Output is correct |
4 | Correct | 66 ms | 10996 KB | Output is correct |
5 | Correct | 124 ms | 13908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 6528 KB | Output is correct |
2 | Correct | 24 ms | 6528 KB | Output is correct |
3 | Correct | 349 ms | 17172 KB | Output is correct |
4 | Correct | 364 ms | 17492 KB | Output is correct |
5 | Correct | 341 ms | 16888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 299 ms | 17344 KB | Output is correct |
2 | Correct | 317 ms | 17272 KB | Output is correct |
3 | Correct | 337 ms | 17784 KB | Output is correct |
4 | Correct | 339 ms | 17832 KB | Output is correct |
5 | Correct | 360 ms | 17748 KB | Output is correct |