Submission #991098

# Submission time Handle Problem Language Result Execution time Memory
991098 2024-06-01T09:33:05 Z stdfloat Crocodile's Underground City (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<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);

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

    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];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 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 4440 KB Output is correct
7 Correct 1 ms 4560 KB Output is correct
8 Correct 1 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 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 4440 KB Output is correct
7 Correct 1 ms 4560 KB Output is correct
8 Correct 1 ms 4556 KB Output is correct
9 Runtime error 138 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 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 4440 KB Output is correct
7 Correct 1 ms 4560 KB Output is correct
8 Correct 1 ms 4556 KB Output is correct
9 Runtime error 138 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -