#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
vector < pair < int, int > > gr[1111];
long long dist[1111];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i = 0; i < M; i ++ ){
gr[R[i][0]].push_back({L[i], R[i][1]});
gr[R[i][1]].push_back({L[i], R[i][0]});
}
for( int i = 0; i < N; i ++ ){
dist[i] = 2e9;
}
for( int i = 0; i < K; i ++ ){
dist[P[i]] = 0;
}
for( int j = 0; j < N; j ++ ){
for( int i = 0; i < N; i ++ ){
long long min1 = 2e9, min2 = 2e9;
for( auto edge: gr[i] ){
int cost = edge.first, to = edge.second;
if(dist[to]+cost<min1){
min2 = min1;
min1 = dist[to] + cost;
}
else if( dist[to]+cost<min2){
min2 = dist[to] + cost;
}
}
//cout << "--> " << j << " : " << i << ' ' << min1 << ' ' << min2<<endl;
dist[i] = min(dist[i], min2);
}
}
/*
for( int i = 0; i < N; i ++ ){
cout << i << ' ' << dist[i] << endl;
}*/
return dist[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
11 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
11 ms |
384 KB |
Output is correct |
8 |
Correct |
12 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
11 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
11 ms |
384 KB |
Output is correct |
8 |
Correct |
12 ms |
384 KB |
Output is correct |
9 |
Correct |
10 ms |
640 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
8 ms |
512 KB |
Output is correct |
12 |
Correct |
15 ms |
768 KB |
Output is correct |
13 |
Correct |
12 ms |
896 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
11 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
11 ms |
384 KB |
Output is correct |
8 |
Correct |
12 ms |
384 KB |
Output is correct |
9 |
Correct |
10 ms |
640 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
8 ms |
512 KB |
Output is correct |
12 |
Correct |
15 ms |
768 KB |
Output is correct |
13 |
Correct |
12 ms |
896 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
512 KB |
Output is correct |
16 |
Runtime error |
391 ms |
35684 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Halted |
0 ms |
0 KB |
- |