Submission #1087812

# Submission time Handle Problem Language Result Execution time Memory
1087812 2024-09-13T09:08:47 Z T0p_ Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
3 ms 7260 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 100000 + 5;
const int MAX_M = 1000000 + 5;

bool is_exit[MAX_N], visited[MAX_M];
vector<pair<int, 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, pair<int, long long>> edge : g[u]) {
    if (edge.second.first == p) continue;

    if (visited[edge.first]) continue;
    visited[edge.first] = true;

    long long res = solve(edge.second.first, u) + edge.second.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({ i, { R[i][1], L[i] }});
    g[R[i][1]].push_back({ i, { 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 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 2 ms 7000 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 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 2 ms 7000 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 6744 KB Output is correct
9 Incorrect 3 ms 7260 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 2 ms 7000 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 6744 KB Output is correct
9 Incorrect 3 ms 7260 KB Output isn't correct
10 Halted 0 ms 0 KB -