Submission #1312916

#TimeUsernameProblemLanguageResultExecution timeMemory
1312916nikaa123Wall (IOI14_wall)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;

const int N = 5e5+5;

int t[4*N];
int lazy1[4*N];
int lazy2[4*N];

void applay(int node, int h, int op) {
  push(node);
  if (op == 1) {
    t[node] = max(t[node],h);
    lazy1[node] = h;
  } else {
    t[node] = min(t[node],h);
    lazy2[node] = h;
  }
}

void push(int node) {
  if (lazy1[node] != -1) {

    applay(node*2,lazy1[node],1);
    applay(node*2+1,lazy1[node],1);
    lazy1[node] = -1;
  }
  if (lazy2[node] != -1) {
    applay(node*2,lazy2[node],2);
    applay(node*2+1,lazy2[node],2);
    lazy2[node] = -1;
  }
}

void update(int node, int l, int r, int L, int R, int h, int op) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    applay(node,h,op);
    return;
  }
  push(node);
  int mid = (l+r)/2;
  update(node*2,l,mid,L,R,h,op);
  update(node*2+1,mid+1,r,L,R,h,op);
}

int getans(int node, int l, int r, int pos) {
  if (l == r) {
    return t[node];
  }
  int mid = (l+r)/2;
  if (pos <= mid) {
    return getans(node*2,l,mid,pos);
  } else {
    return getans(node*2+1,mid+1,r,pos);
  }
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  for (int i = 1; i <= 4*n; i++) {
    lazy1[i] = lazy2[i] = -1;
  }
  for (int i = 1; i <= k; i++) {
    update(1,1,n,left[i]+1,right[i]+1,height[i],op[i]);
  }
  for (int i = 1; i <= n; i++) {
    finalHeight[i-1] = getans(1,1,n,i);
  }
  return;
}

Compilation message (stderr)

wall.cpp: In function 'void applay(int, int, int)':
wall.cpp:12:3: error: 'push' was not declared in this scope
   12 |   push(node);
      |   ^~~~