제출 #597608

#제출 시각아이디문제언어결과실행 시간메모리
597608enerelt14벽 (IOI14_wall)C++14
컴파일 에러
0 ms0 KiB
#include "wall.h" #include<bits/stdc++.h> using namespace std; struct node{ int lazy, mn, mx; node(){ lazy=-1; mn=0; mx=0; } }; node tree[8000005]; void propagate(int id, int l, int r){ if (l==r)return; if (tree[id].lazy!=-1){ tree[id*2+1].lazy=tree[id].lazy; tree[id*2+2].lazy=tree[id].lazy; tree[id*2+1].mn=tree[id].lazy; tree[id*2+2].mn=tree[id].lazy; tree[id*2+1].mx=tree[id].lazy; tree[id*2+2].mx=tree[id].lazy; } tree[id].mn=min(tree[id*2+1].mn, tree[id*2+2].mn); tree[id].mx=max(tree[id*2+1].mx, tree[id*2+2].mx); tree[id].lazy=-1; } void update(int x, int id, int l, int r, int L, int R, int h){ if (l>R || L>r)return; if (!x && tree[id].mn>=h)return; if (x && tree[id].mx<=h)return; propagate(id, l, r); if (L<=l && r<=R){ if (x){ tree[id].lazy=min(tree[id].lazy, h); tree[id].mx=min(tree[id].mx, h); tree[id].mn=min(tree[id].mn, h); } else{ tree[id].lazy=max(tree[id].lazy, h); tree[id].mx=max(tree[id].mx, h); tree[id].mn=max(tree[id].mn, h); } return; } int mid=(l+r)/2; update(x, id*2+1, l, mid, L, R, h); update(x, id*2+2, mid+1, r, L, R, h); tree[id].mn=min(tree[id*2+1].mn, tree[id*2+2].mn); tree[id].mx=max(tree[id*2+1].mx, tree[id*2+2].mx); } int find(int id, int l, int r, int i){ propagate(id, l, r); if (l==r)return tree[id].mn; int mid=(l+r)/2; if (mid<i)return find(id*2+2, mid+1, r, i); else return find(id*2+1, l, mid, i); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ for (int i=0;i<4*n;i++)lazy[i]=-1; for (int i=1;i<=k;i++){ update(op[i]-1, 0, 0, n-1, left[i], right[i], height[i]); } for (int i=0;i<n;i++)finalHeight[i]=find(0, 0, n-1, i); return; }

컴파일 시 표준 에러 (stderr) 메시지

wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:59:28: error: 'lazy' was not declared in this scope
   59 |     for (int i=0;i<4*n;i++)lazy[i]=-1;
      |                            ^~~~