Submission #1087792

# Submission time Handle Problem Language Result Execution time Memory
1087792 2024-09-13T08:42:42 Z T0p_ Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
134 ms 262144 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]) {
    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);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Runtime error 134 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Runtime error 134 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -