답안 #1087791

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087791 2024-09-13T08:39:56 Z T0p_ 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
8 ms 13916 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 100000 + 5;

bool is_exit[MAX_N];
vector<pair<int, long long>> g[MAX_N];

long long solve(int u, int p) {
  if (is_exit[u]) {
    assert(g[u].size() == 1);
    return 0;
  }

  long long mn_1 = 2e9, mn_2 = 2e9;
  for (pair<int, long long> edge : g[u]) {
    if (edge.first == p) continue;

    long long res = solve(edge.first, u) + edge.second;

    if (res < mn_1) {
      mn_2 = mn_1;
      mn_1 = res;
    }
    else {
      mn_2 = min(mn_2, res);
    }
  }

  return mn_2;
}

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

  for (int i=0 ; i<K ; i++) {
    is_exit[P[i]] = true;
  }
  
  return solve(0, -1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6808 KB Output is correct
4 Correct 1 ms 6788 KB Output is correct
5 Correct 1 ms 6796 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6808 KB Output is correct
4 Correct 1 ms 6788 KB Output is correct
5 Correct 1 ms 6796 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Runtime error 8 ms 13916 KB Execution killed with signal 6
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6808 KB Output is correct
4 Correct 1 ms 6788 KB Output is correct
5 Correct 1 ms 6796 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Runtime error 8 ms 13916 KB Execution killed with signal 6
10 Halted 0 ms 0 KB -