답안 #1010132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010132 2024-06-28T11:00:39 Z stdfloat 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
2 ms 604 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> ext, vis;

vector<ll> v;

vector<vector<pii>> E;

void dfs(int x, int p = -1) {
    vis[x] = true;

    if (ext[x]) return v[x] = 0, void();

    for (auto [i, w] : E[x]) {
        if (!vis[i]) dfs(i, x);
    }

    vector<ll> u;
    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]});
    }

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

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

    return v[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -