Submission #385260

# Submission time Handle Problem Language Result Execution time Memory
385260 2021-04-03T21:38:37 Z Pichon5 Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
154 ms 262148 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define lcm(a,b) (a/__gcd(a,b))*b
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define F first
#define S second
using namespace std;
vector<vector<pair<int,int> > >G;
int dp[1005];
void dfs(int nodo,int p){
    vi v;
    for(auto it : G[nodo]){
        if(it.F==p)continue;
        dfs(it.F,nodo);
        v.pb(dp[it.F]+it.S);
    }
    sort(v.begin(),v.end());
    if(G[nodo].size()==1){
        dp[nodo]=0;
    }else{
        dp[nodo]=v[1];
    }
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    //R[i][0] --- R[i][1] con peso L[i]
    G.assign(N+1,vector<pair<int,int> >());
    for(int i=0;i<M;i++){
        int a=R[i][0],b=R[i][1],w=L[i];
        G[a].pb({b,w});
        G[b].pb({a,w});
    }
    dfs(0,-1);
    return dp[0];
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Runtime error 154 ms 262148 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Runtime error 154 ms 262148 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -