Submission #122237

# Submission time Handle Problem Language Result Execution time Memory
122237 2019-06-27T22:48:34 Z joseacaz Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
230 ms 262144 KB
#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 );
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 5 ms 2816 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 4 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 5 ms 2816 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 4 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
9 Runtime error 230 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 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 5 ms 2816 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 4 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
9 Runtime error 230 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -