#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
struct edge{
int to;
int w;
};
vector<edge> adjList[1005];
#define INF INT_MAX
int secondBest(int u,int p)
{
if(adjList[u].size()==1)
return 0;
int a=INF,b=INF;
for(edge e: adjList[u]){
int v=e.to;
if(v==p) continue;
int dist=secondBest(v,u);
if(dist+e.w<a){
b=a;
a=dist+e.w;
}
else if(dist+e.w<b){
b=dist+e.w;
}
}
return b;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i=0;i<M;i++){
int u=R[i][0];
int v=R[i][1];
edge e={v,L[i]};
adjList[u].push_back(e);
e.to=u;
adjList[v].push_back(e);
}
int dist=secondBest(0,-1);
return dist;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
380 KB |
Output is correct |
6 |
Correct |
5 ms |
248 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
380 KB |
Output is correct |
6 |
Correct |
5 ms |
248 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
504 KB |
Output is correct |
9 |
Runtime error |
186 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
380 KB |
Output is correct |
6 |
Correct |
5 ms |
248 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
504 KB |
Output is correct |
9 |
Runtime error |
186 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |