답안 #769925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769925 2023-06-30T13:57:15 Z adrilen 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
121 ms 262144 KB
#include "crocodile.h"
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using arr = array<int, 2>;
using arrr = array<int, 3>;

constexpr int maxn = 1e3;

basic_string <arr> adj[maxn];


bool exit_node[maxn] = { 0 };
int val[maxn] = { 0 };

int dfs(int p, int par)
{
    if (exit_node[p]) return 0;

    multiset <int, greater<int>> s; // Value

    for (arr i : adj[p])
    {
        if (i[0] == par) continue;

        s.insert(dfs(i[0], p) + i[1]);

        if (s.size() > 2) s.erase(s.begin());
    }

    val[p] = *s.begin();
    return val[p];
}


int travel_plan(int n, int m, int R[][2], int L[], int k, int P[])
{
    for (int i = 0; i < m; i++) {
        adj[R[i][0]].push_back({R[i][1], L[i]});
        adj[R[i][1]].push_back({R[i][0], L[i]});
    }  

    for (int i = 0; i < k; i++) exit_node[P[i]] = true;


    return dfs(0, -1);
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Runtime error 121 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Runtime error 121 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -