Submission #1155643

#TimeUsernameProblemLanguageResultExecution timeMemory
1155643a.pendov벽 (IOI14_wall)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "wall.h" using namespace std; const long long MAXN=100009; const long long inf=1000000000; long long max1(long long a,long long b) { if(a>b)return a; return b; } long long min1(long long a,long long b) { if(a<b)return a; return b; } struct node { int l; int r; int minLazy; int maxLazy; void cons(int _l,int _r) { l=_l; r=_r; minLazy=0; maxLazy=inf; } } node tree[4*MAXN]; void build(int n,int l,int r) { tree[n].cons(l,r); if(l==r) { return; } build(2*n,l,(l+r)/2); build(2*n+1,(l+r)/2+1,r); } void push_lazy(int n) { if(tree[n].l==tree[n].r)return; if(tree[n].minLazy>tree[2*n].maxLazy) { tree[2*n].minLazy=tree[2*n].maxLazy; } else { tree[2*n].minLazy=max1(tree[2*n].minLazy,tree[n].minLazy); } if(tree[n].maxLazy<tree[2*n].minLazy) { tree[2*n].maxLazy=tree[2*n].minLazy; } else { tree[2*n].maxLazy=min1(tree[2*n].maxLazy,tree[n].maxLazy); } if(tree[n].minLazy>tree[2*n+1].maxLazy) { tree[2*n+1].minLazy=tree[2*n+1].maxLazy; } else { tree[2*n+1].minLazy=max1(tree[2*n+1].minLazy,tree[n].minLazy); } if(tree[n].maxLazy<tree[2*n+1].minLazy) { tree[2*n+1].maxLazy=tree[2*n+1].minLazy; } else { tree[2*n+1].maxLazy=min1(tree[2*n+1].maxLazy,tree[n].maxLazy); } tree[n].minLazy=0; tree[n].maxLazy=inf; } void addChange(int n,int l,int r,int v) { push_lazy(n); if(tree[n].l==l&&tree[n].r==r) { if(v>tree[n].maxLazy) { tree[n].minLazy=tree[n].maxLazy; } else { tree[n].minLazy=max1(tree[n].minLazy,v); } } if(tree[2*n].r<l) { addChange(2*n+1,l,r,v); return; } if(tree[2*n+1].l>r) { addChange(2*n,l,r,v); return; } addChange(2*n,l,tree[2*n].r,v); addChange(2*n+1,tree[2*n+1].l,r,v); } void remChange(int n,int l,int r,int v) { push_lazy(n); if(tree[n].l==l&&tree[n].r==r) { if(v<tree[n].minLazy) { tree[n].maxLazy=tree[n].minLazy; } else { tree[n].maxLazy=min1(tree[n].maxLazy,v); } } if(tree[2*n].r<l) { remChange(2*n+1,l,r,v); return; } if(tree[2*n+1].l>r) { remChange(2*n,l,r,v); return; } remChange(2*n,l,tree[2*n].r,v); remChange(2*n+1,tree[2*n+1].l,r,v); } long long getAns(int n,int t) { push_lazy(n); if(tree[n].l==l&&tree[n].r==r) { return tree[n].minLazy; } if(tree[2*n].r<t) { return getAns(2*n+1,t); } if(tree[2*n+1].l>t) { return getAns(2*n,t); } return -1; } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { build(1,0,N-1) for(int i=0;i<k;i++) { if(op[i]==1) { addChange(1,l[i],r[i],height[i]); } else { remChange(1,l[i],r[i],height[i]); } } for(int i=0;i<N;i++) { finalHeigth[i]=getAns(1,i,i); } }

Compilation message (stderr)

wall.cpp:34:6: error: expected initializer before 'tree'
   34 | node tree[4*MAXN];
      |      ^~~~
wall.cpp: In function 'void build(int, int, int)':
wall.cpp:38:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   38 |     tree[n].cons(l,r);
      |     ^~~~
      |     free
wall.cpp: In function 'void push_lazy(int)':
wall.cpp:49:8: error: 'tree' was not declared in this scope; did you mean 'free'?
   49 |     if(tree[n].l==tree[n].r)return;
      |        ^~~~
      |        free
wall.cpp:51:8: error: 'tree' was not declared in this scope; did you mean 'free'?
   51 |     if(tree[n].minLazy>tree[2*n].maxLazy)
      |        ^~~~
      |        free
wall.cpp:60:8: error: 'tree' was not declared in this scope; did you mean 'free'?
   60 |     if(tree[n].maxLazy<tree[2*n].minLazy)
      |        ^~~~
      |        free
wall.cpp:70:8: error: 'tree' was not declared in this scope; did you mean 'free'?
   70 |     if(tree[n].minLazy>tree[2*n+1].maxLazy)
      |        ^~~~
      |        free
wall.cpp:79:8: error: 'tree' was not declared in this scope; did you mean 'free'?
   79 |     if(tree[n].maxLazy<tree[2*n+1].minLazy)
      |        ^~~~
      |        free
wall.cpp:88:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   88 |     tree[n].minLazy=0;
      |     ^~~~
      |     free
wall.cpp: In function 'void addChange(int, int, int, int)':
wall.cpp:95:8: error: 'tree' was not declared in this scope; did you mean 'free'?
   95 |     if(tree[n].l==l&&tree[n].r==r)
      |        ^~~~
      |        free
wall.cpp:107:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  107 |     if(tree[2*n].r<l)
      |        ^~~~
      |        free
wall.cpp:113:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  113 |     if(tree[2*n+1].l>r)
      |        ^~~~
      |        free
wall.cpp:119:21: error: 'tree' was not declared in this scope; did you mean 'free'?
  119 |     addChange(2*n,l,tree[2*n].r,v);
      |                     ^~~~
      |                     free
wall.cpp: In function 'void remChange(int, int, int, int)':
wall.cpp:126:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  126 |     if(tree[n].l==l&&tree[n].r==r)
      |        ^~~~
      |        free
wall.cpp:138:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  138 |     if(tree[2*n].r<l)
      |        ^~~~
      |        free
wall.cpp:144:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  144 |     if(tree[2*n+1].l>r)
      |        ^~~~
      |        free
wall.cpp:150:21: error: 'tree' was not declared in this scope; did you mean 'free'?
  150 |     remChange(2*n,l,tree[2*n].r,v);
      |                     ^~~~
      |                     free
wall.cpp: In function 'long long int getAns(int, int)':
wall.cpp:157:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  157 |     if(tree[n].l==l&&tree[n].r==r)
      |        ^~~~
      |        free
wall.cpp:157:19: error: 'l' was not declared in this scope
  157 |     if(tree[n].l==l&&tree[n].r==r)
      |                   ^
wall.cpp:157:33: error: 'r' was not declared in this scope
  157 |     if(tree[n].l==l&&tree[n].r==r)
      |                                 ^
wall.cpp:162:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  162 |     if(tree[2*n].r<t)
      |        ^~~~
      |        free
wall.cpp:167:8: error: 'tree' was not declared in this scope; did you mean 'free'?
  167 |     if(tree[2*n+1].l>t)
      |        ^~~~
      |        free
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:177:15: error: 'N' was not declared in this scope
  177 |     build(1,0,N-1)
      |               ^
wall.cpp:179:17: error: 'i' was not declared in this scope
  179 |     for(int i=0;i<k;i++)
      |                 ^
wall.cpp:193:9: error: 'finalHeigth' was not declared in this scope; did you mean 'finalHeight'?
  193 |         finalHeigth[i]=getAns(1,i,i);
      |         ^~~~~~~~~~~
      |         finalHeight
wall.cpp:193:30: error: too many arguments to function 'long long int getAns(int, int)'
  193 |         finalHeigth[i]=getAns(1,i,i);
      |                        ~~~~~~^~~~~~~
wall.cpp:154:11: note: declared here
  154 | long long getAns(int n,int t)
      |           ^~~~~~