# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308536 | kylych03 | Crocodile's Underground City (IOI11_crocodile) | C++14 | 188 ms | 262148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "crocodile.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
vector <pair <int, int > > g[1002];
int vis[1002], vis1[1001];
int inf =1e9;
int dfs(int v, int p ){
vector <int> vec;
if(vis[v])
return 0;
for(int i = 0 ; i<g[v].size() ; i++){
int to = g[v][i].first;
if(to==p || vis1[p])
continue;
vec.push_back ( dfs(to, v) + g[v][i].second);
}
sort(vec.begin(), vec.end());
vis1[v]=1;
if(vec.size() > 1)
return vec[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i = 0 ; i < M ;i++){
g[R[i][0]].push_back(make_pair (R[i][1], L[i]) );
g[R[i][1]].push_back( make_pair (R[i][0], L[i]));
}
for(int i = 0; i < K; i++)
vis[P[i]] = 1;
int x = dfs(0, -1);
return x;
}
/*
5 4 3
0 1 2
0 2 3
3 2 1
2 4 4
1 3 4
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |