Submission #569746

#TimeUsernameProblemLanguageResultExecution timeMemory
569746turbilegRoad Closures (APIO21_roads)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
//#include "jumps.h"

#include <vector>

using namespace std;

std::vector<int> H;
std::vector<int> v;
int a[20005];
int ans;
int n;

void init(int N, std::vector<int> H) {
  v = H;
  n = N;
}

int minimum_jumps(int A, int B, int C, int D) {
  for (int i = 0; i < n; i++) {
    int x = -1e6, y = 1e6;

    if (v[i] == n) {
      v[i] = n;
      continue;
    }

    for (int j = i - 1; j >= 0; j--) {
      if(v[j] > v[i]) {
        x = j;
        break;
      }
    }

    for (int j = i + 1; j < n; j++) {
      if(v[j] > v[i]) {
        y = j;
        break;
      }
    }

    if(y - i > i - x) a[i] = x;
    else if(y - i < i - x) a[i] = y;
    else {
      /*if (v[x] > v[y]) a[i] = x;
      else a[i] = y;*/
      a[i] = x;
    }
  }

  int mx = 0;
  for (int i = C; i <= D; i++) {
    if(v[i] > mx) mx = v[i];
  }

  int ans = 1e6;
  for(int i = A; i <= B; i++) {
    int p = i;
    int res = 0;

    while (p < n) {
      res ++;
      p = a[p];

      if(C <= p && p <= D) {
        if(ans > res) {
          ans = res;
        }

        break;
      }

      if(v[p] > mx) break;
    }
  }

  if (ans == 1e6) return -1;
  else return ans;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccw2DYTu.o: in function `main':
grader.cpp:(.text.startup+0x26f): undefined reference to `minimum_closure_costs(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status