#include <bits/stdc++.h>
#include "obstacles.h"
using namespace std;
static int N, M;
static vector<int> Tval, Hval;
static vector<int> freecol; // freecol[j] = 1 if T[0] > H[j]
static vector<int> nxt_block; // nearest blocked cell to the right
void initialize(vector<int> T, vector<int> H) {
Tval = T;
Hval = H;
N = Tval.size();
M = Hval.size();
freecol.assign(M, 0);
nxt_block.assign(M, -1);
int baseT = Tval[0]; // Only row 0 matters in Subtask 1
for (int j = 0; j < M; j++)
freecol[j] = (baseT >= Hval[j]) ? 0 : 1;
int last = M-1; // sentinel for "no block to the right"
for (int j = M - 1; j >= 0; j--) {
if (freecol[j] == 1) {
last = j;
} else {
nxt_block[j] = last - 1; // first reachable free col to right - 1
}
}
}
bool can_reach(int L, int R, int S, int D) {
// Subtask 1 guarantee: L = 0, R = M-1 always.
// If nxt_block[a] >= b then columns a..b are all free.
return nxt_block[min(S,D)] >= max(D,S);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |