답안 #319913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319913 2020-11-06T18:22:42 Z knon0501 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
206 ms 262148 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

int n;
vector<pair<int,int>> a[100001];
long long dp[100001];
int chk[100001];
long long dfs(int v,int p){
    if(chk[v])return dp[v]=0;
    vector<long long> b;
    for(auto u: a[v]){
        if(u.first==p)continue;
        b.push_back(dfs(u.first,v)+u.second);
    }
    sort(b.begin(),b.end());
    if(b.size()<=1)return 1e18;
    return dp[v]=b[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n=N;
    int i,j;
    for(i=0 ; i<K ; i++)chk[P[i]]=1;
    for(i=0 ; i<M ; i++){
        int u=R[i][0];
        int v=R[i][1];
        a[u].push_back({v,L[i]});
        a[v].push_back({u,L[i]});
    }
    dfs(0,-1);

    return dp[0];
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:23:11: warning: unused variable 'j' [-Wunused-variable]
   23 |     int i,j;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2924 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2924 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
9 Runtime error 206 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2924 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
9 Runtime error 206 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -