#include "crocodile.h"
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
const int inf=1e3+9,MX=1e9+9;
vector< pair<int,int> > adj[inf];
bool ex[inf];
int dp[inf];
void dfs(int u,int par){
if(ex[u])
return ;
vector<int> tmp = {MX,MX,MX};
for(auto v:adj[u])
if( v.first != par )
dfs(v.first , u) , tmp[2] = dp[v.first]+v.second,sort(tmp.begin(),tmp.end());
dp[u] = tmp[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
for(int i=0;i<M;i++)
adj[ R[i][0] ].push_back( make_pair( R[i][1] , L[i] ) ),
adj[ R[i][1] ].push_back(make_pair( R[i][0] , L[i] ));
for(int i=0;i<K;i++)
ex[ P[i] ] = 1;
dfs(0,-1);
return dp[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Runtime error |
298 ms |
262144 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 |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Runtime error |
298 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |