답안 #337015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337015 2020-12-17T21:37:15 Z r_v_n 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
178 ms 262148 KB
using namespace std;
#include <bits/stdc++.h>
#define ll long long
int dp[100001];
int n;
int m, k;
vector<pair<int, int>> adj[100001];
map<int, int> is;
void dfs(int v, int p = -1)
{
    if (adj[v].size() == 1)
    {
        if (is[v])
            dp[v] = 0;
        else
            dp[v] = 1e9;
        return;
    }
    vector<int> store;
    for (auto it : adj[v])
    {
        if (it.first == p)
            continue;
        dfs(it.first, v);
        store.push_back(dp[it.first] + it.second);
    }
    sort(store.begin(), store.end());
    dp[v] = store[1];
}
// void solve()
// {
//     cin >> n >> m >> k;
//     for (int i = 0; i <= n; i++)
//     {
//         adj[i].clear();
//         dp[i] = 0;
//     }
//     is.clear();
//     for (int i = 0; i < m; i++)
//     {
//         int a, b, c;
//         cin >> a >> b >> c;
//         adj[a].push_back({b, c});
//         adj[b].push_back({a, c});
//     }
//     for (int i = 0; i < k; i++)
//     {
//         int a;
//         cin >> a;
//         is[a] = 1;
//     }
//     dfs(0);
//     cout << dp[0] << endl;
// }
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(make_pair(R[i][1], L[i]));
        adj[R[i][1]].push_back(make_pair(R[i][0], L[i]));
    }
    for(int i=0;i<K;i++)
    {
        is[P[i]]=1;
    }
    dfs(0);
    return dp[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Runtime error 178 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Runtime error 178 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -