#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
constexpr static int MXN = 2e5 + 5;
int k, n;
int fw[MXN];
void update(int i, int val) { for (i++;i<MXN;i+=i&(-i)) fw[i] += val; }
int get(int i) { int res = 0; for (i++;i;i-=i&(-i)) res += fw[i]; return res; }
int get(int l, int r) { return get(r) - get(l); }
int v[MXN];
int succ[MXN];
void init(int _k, vector<int> r)
{
debug(r);
n = r.size();
k = _k;
assert(k * 2 > n);
fill(succ, succ + n, -1);
for (int i = 1; i <= n; i++)
{
int prev = -1;
int current = -1;
int first = MXN;
for (int j = 0; j < n; j++)
{
if (v[j])
continue;
int ll = j+1;
int rr = j+k;
int pc = 0;
if (rr > n)
{
pc += get(ll, n);
pc += get(0, rr-n);
}
else
{
pc += get(ll, rr);
}
if (pc + r[j] < k-1)
continue;
first = min(first, j);
if (prev != -1 && j - prev >= k)
current = j;
}
if (current == -1)
current = first;
debug(current);
v[current] = i;
update(current, 1);
}
}
int compare_plants(int x, int y)
{
if (v[x] > v[y])
return 1;
if (v[y] > v[x])
return -1;
return 0;
}
Compilation message
plants.cpp:7:10: fatal error: ../debug.h: No such file or directory
7 | #include "../debug.h"
| ^~~~~~~~~~~~
compilation terminated.