Submission #597607

#TimeUsernameProblemLanguageResultExecution timeMemory
597607enerelt14벽 (IOI14_wall)C++14
Compilation error
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;
}

Compilation message (stderr)

wall.cpp:12:6: error: expected initializer before 'tree'
   12 | node tree[8000005];
      |      ^~~~
wall.cpp: In function 'void propagate(int, int, int)':
wall.cpp:15:9: error: 'tree' was not declared in this scope; did you mean 'free'?
   15 |     if (tree[id].lazy!=-1){
      |         ^~~~
      |         free
wall.cpp:23:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   23 |     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:29:15: error: 'tree' was not declared in this scope; did you mean 'free'?
   29 |     if (!x && tree[id].mn>=h)return;
      |               ^~~~
      |               free
wall.cpp:30:14: error: 'tree' was not declared in this scope; did you mean 'free'?
   30 |     if (x && tree[id].mx<=h)return;
      |              ^~~~
      |              free
wall.cpp:34:13: error: 'tree' was not declared in this scope; did you mean 'free'?
   34 |             tree[id].lazy=min(tree[id].lazy, h);
      |             ^~~~
      |             free
wall.cpp:39:13: error: 'tree' was not declared in this scope; did you mean 'free'?
   39 |             tree[id].lazy=max(tree[id].lazy, h);
      |             ^~~~
      |             free
wall.cpp:48:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   48 |     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:53:21: error: 'tree' was not declared in this scope; did you mean 'free'?
   53 |     if (l==r)return tree[id].mn;
      |                     ^~~~
      |                     free
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;
      |                            ^~~~