답안 #927223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927223 2024-02-14T12:54:17 Z Nurislam 벽 (IOI14_wall) C++14
컴파일 오류
0 ms 0 KB
int add[N*4],rem[N*4];
void build(int v,int tl,int tr){
   if(tl==tr){
      add[v]=0;
      rem[v]=1e9;
   }
   else{
      int tm=(tl+tr)/2;
      build(v*2,tl,tm);
      build(v*2+1,tm+1,tr);
   }
}
void push(int v){
   add[v*2]=max(add[v*2],add[v]);
   rem[v*2]=max(rem[v*2],add[v]);
   add[v*2]=min(add[v*2],rem[v]);
   rem[v*2]=min(rem[v*2],rem[v]);
   add[v*2+1]=max(add[v*2+1],add[v]);
   rem[v*2+1]=max(rem[v*2+1],add[v]);
   add[v*2+1]=min(add[v*2+1],rem[v]);
   rem[v*2+1]=min(rem[v*2+1],rem[v]);
   add[v]=0;rem[v]=1e9;
}
void update(int v,int tl,int tr,int l,int r,int x,int type){
   if(r<tl or l>tr)return;
   if(l<=tl && tr<=r){
      if(type==1){
         add[v]=max(add[v],x);
         rem[v]=max(rem[v],x);
      }
      else{
         add[v]=min(add[v],x);
         rem[v]=min(rem[v],x);
      }
      return;
   }
   push(v);
   int tm=(tl+tr)/2;
   update(v*2,tl,tm,l,r,x,type);
   update(v*2+1,tm+1,tr,l,r,x,type);
}
int get(int v,int tl,int tr,int pos){
   if(tl==tr)return add[v];
   push(v);
   int tm=(tl+tr)/2;
   if(pos<=tm)return get(v*2,tl,tm,pos);
   else return get(v*2+1,tm+1,tr,pos);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
   build(1,1,n);
   for(int i=0;i<k;i++){
      update(1,1,n,left[i]+1,right[i]+1,height[i],op[i]);
   }
   for(int i=0;i<n;i++){
      finalHeight[i]=get(1,1,n,i+1);
   }
  return;
}

Compilation message

wall.cpp:1:9: error: 'N' was not declared in this scope
    1 | int add[N*4],rem[N*4];
      |         ^
wall.cpp:1:18: error: 'N' was not declared in this scope
    1 | int add[N*4],rem[N*4];
      |                  ^
wall.cpp: In function 'void build(int, int, int)':
wall.cpp:4:7: error: 'add' was not declared in this scope
    4 |       add[v]=0;
      |       ^~~
wall.cpp:5:7: error: 'rem' was not declared in this scope
    5 |       rem[v]=1e9;
      |       ^~~
wall.cpp: In function 'void push(int)':
wall.cpp:14:4: error: 'add' was not declared in this scope
   14 |    add[v*2]=max(add[v*2],add[v]);
      |    ^~~
wall.cpp:14:13: error: 'max' was not declared in this scope
   14 |    add[v*2]=max(add[v*2],add[v]);
      |             ^~~
wall.cpp:15:4: error: 'rem' was not declared in this scope
   15 |    rem[v*2]=max(rem[v*2],add[v]);
      |    ^~~
wall.cpp:16:13: error: 'min' was not declared in this scope
   16 |    add[v*2]=min(add[v*2],rem[v]);
      |             ^~~
wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:28:10: error: 'add' was not declared in this scope
   28 |          add[v]=max(add[v],x);
      |          ^~~
wall.cpp:28:17: error: 'max' was not declared in this scope
   28 |          add[v]=max(add[v],x);
      |                 ^~~
wall.cpp:29:10: error: 'rem' was not declared in this scope
   29 |          rem[v]=max(rem[v],x);
      |          ^~~
wall.cpp:32:10: error: 'add' was not declared in this scope
   32 |          add[v]=min(add[v],x);
      |          ^~~
wall.cpp:32:17: error: 'min' was not declared in this scope
   32 |          add[v]=min(add[v],x);
      |                 ^~~
wall.cpp:33:10: error: 'rem' was not declared in this scope
   33 |          rem[v]=min(rem[v],x);
      |          ^~~
wall.cpp: In function 'int get(int, int, int, int)':
wall.cpp:43:21: error: 'add' was not declared in this scope
   43 |    if(tl==tr)return add[v];
      |                     ^~~