답안 #649362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
649362 2022-10-10T05:58:30 Z mychecksedad 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
129 ms 262144 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 1e6;



int n, m;
vector<int> dist[N], dp(N);
vector<pair<int, int>> g[N];
bitset<N> is;

void dfs(int v, int p){
    if(is[v]){
        return;
    }
    for(auto k: g[v]){
        int u = k.first, e = k.second;
        if(u == p) continue;
        dfs(u, v);
    }
    for(auto k: g[v]){
        int u = k.first, e = k.second;
        if(u == p) continue;
        int dist = 1e9;
        for(auto k1: g[v]){
            int u1 = k1.first, e1 = k1.second;
            if(u1 == p || u1 == u) continue;
            dist = min(dist, dp[u1] + e1);
        } 
        dp[v] = max(dp[v], dist);
    }
}

int travel_plan(int F, int M, int R[][2], int L[], int K, int P[]){ 
    n = F;
    m = M;
    for(int i = 0; i < K; ++i) is[P[i]] = 1;
    for(int i = 0; i < m; ++i){
        g[R[i][0]].pb({R[i][1], L[i]});
        g[R[i][1]].pb({R[i][0], L[i]});
    }
    dfs(0, 0);

    return dp[0];
}

Compilation message

crocodile.cpp: In function 'void dfs(int, int)':
crocodile.cpp:19:26: warning: unused variable 'e' [-Wunused-variable]
   19 |         int u = k.first, e = k.second;
      |                          ^
crocodile.cpp:24:26: warning: unused variable 'e' [-Wunused-variable]
   24 |         int u = k.first, e = k.second;
      |                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 51148 KB Output is correct
2 Correct 25 ms 51256 KB Output is correct
3 Correct 25 ms 51148 KB Output is correct
4 Correct 25 ms 51216 KB Output is correct
5 Correct 25 ms 51268 KB Output is correct
6 Correct 26 ms 51276 KB Output is correct
7 Correct 27 ms 51204 KB Output is correct
8 Correct 24 ms 51284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 51148 KB Output is correct
2 Correct 25 ms 51256 KB Output is correct
3 Correct 25 ms 51148 KB Output is correct
4 Correct 25 ms 51216 KB Output is correct
5 Correct 25 ms 51268 KB Output is correct
6 Correct 26 ms 51276 KB Output is correct
7 Correct 27 ms 51204 KB Output is correct
8 Correct 24 ms 51284 KB Output is correct
9 Runtime error 129 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 51148 KB Output is correct
2 Correct 25 ms 51256 KB Output is correct
3 Correct 25 ms 51148 KB Output is correct
4 Correct 25 ms 51216 KB Output is correct
5 Correct 25 ms 51268 KB Output is correct
6 Correct 26 ms 51276 KB Output is correct
7 Correct 27 ms 51204 KB Output is correct
8 Correct 24 ms 51284 KB Output is correct
9 Runtime error 129 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -