# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
10375 |
2014-10-20T13:27:28 Z |
gs14004 |
Ferries (NOI13_ferries) |
C++ |
|
288 ms |
15888 KB |
#include <cstdio>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
priority_queue<int> len[100005];
vector<int> graph[100005];
priority_queue<pi,vector<pi>,greater<pi> > pq;
int n,m,v[100005];
int main(){
scanf("%d %d",&n,&m);
for (int i=0; i<m; i++) {
int p,q,r;
scanf("%d %d %d",&p,&q,&r);
graph[q].push_back(p);
len[p].push(r);
}
pq.push(pi(0,n));
while (!pq.empty()) {
pi x = pq.top();
pq.pop();
if(x.second == 1){
printf("%d",x.first);
break;
}
if(v[x.second]) continue;
v[x.second] = 1;
for (int i=0; i<graph[x.second].size(); i++) {
int pos = graph[x.second][i];
if(v[pos]) continue;
int newlen = len[pos].top();
len[pos].pop();
pq.push(pi(newlen + x.first,pos));
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7068 KB |
Output is correct |
2 |
Correct |
4 ms |
7068 KB |
Output is correct |
3 |
Correct |
8 ms |
7948 KB |
Output is correct |
4 |
Correct |
144 ms |
15888 KB |
Output is correct |
5 |
Correct |
140 ms |
15888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7068 KB |
Output is correct |
2 |
Correct |
4 ms |
7068 KB |
Output is correct |
3 |
Correct |
4 ms |
8012 KB |
Output is correct |
4 |
Correct |
68 ms |
11484 KB |
Output is correct |
5 |
Correct |
84 ms |
13576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
7728 KB |
Output is correct |
2 |
Correct |
16 ms |
7728 KB |
Output is correct |
3 |
Correct |
224 ms |
13800 KB |
Output is correct |
4 |
Correct |
288 ms |
14260 KB |
Output is correct |
5 |
Correct |
256 ms |
14264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
252 ms |
13800 KB |
Output is correct |
2 |
Correct |
236 ms |
13800 KB |
Output is correct |
3 |
Correct |
180 ms |
14064 KB |
Output is correct |
4 |
Correct |
264 ms |
14668 KB |
Output is correct |
5 |
Correct |
244 ms |
14676 KB |
Output is correct |