# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
122236 | joseacaz | Crocodile's Underground City (IOI11_crocodile) | C++17 | 0 ms | 0 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>
#define MAX_N 50000
#define MAX_M 10000000
#define MAXN 100005
#define MAXM 1000005
static int _N, _M;
static int _R[MAX_M][2];
static int _L[MAX_M];
static int _K;
static int _P[MAX_N];
static int _solution;
inline
void my_assert(int e) {if (!e) abort();}
///SUBMITEAR DESDE AQUI:
/*
#include "crocodile.h"
#include <bits/stdc++.h>
#define MAXN 100005
#define MAXM 1000005*/
using namespace std;
typedef long long ll;
int N, M, K, R[MAXM][2], L[MAXM], P[MAXN];
vector < pair < int, ll > > Graph[MAXN];
ll dfs ( int node, int p = -1 )
{
if ( Graph[node].size() == 1 )
return 0;
vector < ll > A;
A.clear();
for ( auto i : Graph[node] )
if ( i.first != p )
A.push_back ( dfs ( i.first, node ) + i.second );
sort ( A.begin(), A.end() );
return A[1];
}
int travel_plan ( int n, int m, int r[][2], int l[], int k, int p[] )
{
N = n;
M = m;
for ( int i = 0; i < M; i++ )
R[i][0] = r[i][0], R[i][1] = r[i][1], L[i] = l[i];
K = k;
for ( int i = 0; i < K; i++ )
P[i] = p[i];
for ( int i = 0; i < M; i++ )
{
Graph[R[i][0]].push_back ( {R[i][1], L[i]} );
Graph[R[i][1]].push_back ( {R[i][0], L[i]} );
}
return dfs ( 0 );
}
void read_input()
{
int i;
my_assert(3==scanf("%d %d %d",&_N,&_M,&_K));
for(i=0; i<_M; i++)
my_assert(3==scanf("%d %d %d",&_R[i][0],&_R[i][1],&_L[i]));
for(i=0; i<_K; i++)
my_assert(1==scanf("%d",&_P[i]));
my_assert(1==scanf("%d",&_solution));
}
int main()
{
int _ans;
read_input();
_ans = travel_plan(_N,_M,_R,_L,_K,_P);
if(_ans==_solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d, Expected %d.\n",_ans,_solution);
return 0;
}