#include "crocodile.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
const int maxx = 1000;
int ext[maxx];
vector< pair<int,int> >adj[maxx];
vector< int > thru[maxx];
void dfs(int s,int p) {
if (ext[s])return;
for (auto to : adj[s]) {
if (to.F == p)continue;
dfs(to.F , s);
if (ext[to.F])thru[s].push_back(to.S);
else if (thru[to.F].size() == 2) thru[s].push_back(max(thru[to.F][0] , thru[to.F][1] + to.S));
}
if (thru[s].size() < 2)thru[s].clear();
sort(thru[s].begin(),thru[s].end());
while (thru[s].size() > 2)thru[s].pop_back();
}
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
for (int i = 0;i<m;i++) {
int x = R[i][0] , y = R[i][1];
adj[x].push_back( {y , L[i]} );
adj[y].push_back( {x , L[i]} );
}
for (int i = 0;i<k;i++) ext[P[i]] = 1;
dfs(0 , -1);
return thru[0][1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Runtime error |
256 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 |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |