Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

class segtree {
    int n = 1; VI mindat, maxdat;
public:
    segtree(VI a) {
        int _n = a.size();
        while (n < _n)n *= 2;
        mindat.resize(2 * n - 1, INF);
        maxdat.resize(2 * n - 1, 0);
        FOR(i, 0, _n)mindat[i + n - 1] = maxdat[i + n - 1] = a[i];
        rFOR(i, 0, n - 1) {
            mindat[i] = min(mindat[2 * i + 1], mindat[2 * i + 2]);
            maxdat[i] = max(maxdat[2 * i + 1], maxdat[2 * i + 2]);
        }
    }
    int Min(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a)return INF;
        if (a <= l && r <= b)return mindat[k];
        else {
            int s = Min(a, b, 2 * k + 1, l, (l + r) / 2);
            int t = Min(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(s, t);
        }
    }
    int Min(int a, int b) { return Min(a, b, 0, 0, n); }
    int Max(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a)return 0;
        if (a <= l && r <= b)return maxdat[k];
        else {
            int s = Max(a, b, 2 * k + 1, l, (l + r) / 2);
            int t = Max(a, b, 2 * k + 2, (l + r) / 2, r);
            return max(s, t);
        }
    }
    int Max(int a, int b) { return Max(a, b, 0, 0, n); }
};

int main() {
    init();

    int n, k;
    cin >> n >> k;
    VI p(n);
    FOR(i, 0, n)cin >> p[i];

    segtree seg(p);

    vector<bool> isSorted(n - k + 1);
    int cnt = 0, itr = 1;
    FOR(i, 0, n - k + 1) {
        while (itr < i + k) {
            if (p[itr - 1] > p[itr])cnt++;
            itr++;
        }
        isSorted[i] = (cnt == 0);
        if (p[i] > p[i + 1])cnt--;
    }

    vector<bool> New(n - k + 1, false);
    New[0] = true;
    FOR(i, 0, n - k) {
        int MAX = seg.Max(i, i + k);
        int MIN = seg.Min(i, i + k);
        New[i + 1] = !(p[i] == MIN && MAX < p[i + k]);
    }

    int ans = 0;
    bool plus = false;
    FOR(i, 0, n - k + 1) {
        if (isSorted[i])plus = true;
        else if(&New[i])ans++;
    }
    if (plus)ans++;

    cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:91:23: error: taking address of rvalue [-fpermissive]
   91 |         else if(&New[i])ans++;
      |                  ~~~~~^