Submission #1261562

#TimeUsernameProblemLanguageResultExecution timeMemory
1261562avighnaObstacles for a Llama (IOI25_obstacles)C++20
10 / 100
69 ms9032 KiB
#include "obstacles.h"

std::vector<int> h, t;
std::vector<int> psum;
int m;

bool b(int i, int j) {
  return t[i] > h[j];
}

void initialize(std::vector<int> T, std::vector<int> H) {
  h = H, t = T;
  m = h.size();
  psum.resize(m);
  psum[0] = b(0, 0);
  for (int j = 1; j < m; ++j) {
    psum[j] = psum[j - 1] + b(0, j);
  }
}

bool can_reach(int l, int r, int s, int d) {
  // s d should be a subrange of l r
  // l s d r
  if (l > s or d > r) {
    return false;
  }
  int val = psum[d];
  if (s != 0) {
    val -= psum[s - 1];
  }
  return val == d - s + 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...