답안 #991100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991100 2024-06-01T09:34:19 Z stdfloat 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
138 ms 262144 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

#define ff  first
#define ss  second
#define pii pair<int, int>

using ll = long long;

vector<bool> vis;

vector<int> u;

vector<ll> v;

vector<vector<pii>> E;

void dfs(int x, int p = -1) {
    if (vis[x]) {
        v[x] = 0;
        return;
    }

    for (auto [i, w] : E[x])
        if (i != p) dfs(i, x);

    u.clear();
    for (auto [i, w] : E[x]) {
        if (i != p && v[i] != LLONG_MAX) u.push_back(v[i] + w);
    }

    sort(u.begin(), u.end());

    if (1 < (int)u.size()) v[x] = u[1];
}

int travel_plan(int n, int M, int R[][2], int L[], int K, int P[]) {
    E.assign(n, {});
    for (int i = 0; i < M; i++) {
        E[R[i][0]].push_back({R[i][1], L[i]});
        E[R[i][1]].push_back({R[i][0], L[i]});
    }

    vis.assign(n, false);
    for (int i = 0; i < K; i++)
        vis[P[i]] = true;

    v.assign(n, LLONG_MAX);
    dfs(0);

    return v[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Runtime error 138 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Runtime error 138 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -