제출 #597606

#제출 시각아이디문제언어결과실행 시간메모리
597606enerelt14벽 (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; } } 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:11:2: error: expected ';' after struct definition
   11 | }
      |  ^
      |  ;
wall.cpp: In function 'void propagate(int, int, int)':
wall.cpp:14:9: error: 'tree' was not declared in this scope; did you mean 'free'?
   14 |     if (tree[id].lazy!=-1){
      |         ^~~~
      |         free
wall.cpp:22:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   22 |     tree[id].mn=min(tree[id*2+1].mn, tree[id*2+2].mn);
      |     ^~~~
      |     free
wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:28:15: error: 'tree' was not declared in this scope; did you mean 'free'?
   28 |     if (!x && tree[id].mn>=h)return;
      |               ^~~~
      |               free
wall.cpp:29:14: error: 'tree' was not declared in this scope; did you mean 'free'?
   29 |     if (x && tree[id].mx<=h)return;
      |              ^~~~
      |              free
wall.cpp:33:13: error: 'tree' was not declared in this scope; did you mean 'free'?
   33 |             tree[id].lazy=min(tree[id].lazy, h);
      |             ^~~~
      |             free
wall.cpp:38:13: error: 'tree' was not declared in this scope; did you mean 'free'?
   38 |             tree[id].lazy=max(tree[id].lazy, h);
      |             ^~~~
      |             free
wall.cpp:47:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   47 |     tree[id].mn=min(tree[id*2+1].mn, tree[id*2+2].mn);
      |     ^~~~
      |     free
wall.cpp: In function 'int find(int, int, int, int)':
wall.cpp:52:21: error: 'tree' was not declared in this scope; did you mean 'free'?
   52 |     if (l==r)return tree[id].mn;
      |                     ^~~~
      |                     free
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:58:28: error: 'lazy' was not declared in this scope
   58 |     for (int i=0;i<4*n;i++)lazy[i]=-1;
      |                            ^~~~