제출 #472680

#제출 시각아이디문제언어결과실행 시간메모리
472680Haidara벽 (IOI14_wall)C++17
컴파일 에러
0 ms0 KiB
#include"wall.h"
#define FOR(i,n) for(int i=0;i<n;i++)
using namespace std;
const int maxn=2000200;
int n;
const int inf=1LL<<30LL;
struct node
{
    int mx=inf,mn=0,lazy=-1;
} st[maxn*2+2];
bool add=0;
int ul,ur,val;
void pull(int inx,int l,int r)
{
    if(st[inx].lazy==-1)
        return ;
    if(add)
    {
        st[inx].mn=max(st[inx].lazy,st[inx].mn);
        st[inx].mx=max(st[inx].mn,st[inx].mx);
        if(l!=r)
        {
            st[inx*2].lazy=max(st[inx].lazy,st[inx*2].lazy);
            st[inx*2+1].lazy=max(st[inx].lazy,st[inx*2+1].lazy);
        }
    }
    else
    {
        st[inx].mx=min(st[inx].mx,st[inx].lazy);
        st[inx].mn=min(st[inx].mn,st[inx].mx);
        if(l!=r)
        {
            st[inx*2].lazy=min(st[inx].lazy,st[inx*2].lazy);
            st[inx*2+1].lazy=min(st[inx].lazy,st[inx*2+1].lazy);
        }
    }
    st[inx].lazy=-1;
}
int check(int inx,int type)
{

    int mintall=st[inx].mn,maxtall=st[inx].mx;
    if(st[inx].lazy!=-1)
    {
        if(add)
        {
            mintall=max(st[inx].lazy,st[inx].mn);
            maxtall=max(st[inx].mn,st[inx].mx);
        }
        else
        {
            maxtall=min(st[inx].mx,st[inx].lazy);
            mintall=min(st[inx].mn,st[inx].mx);
        }
    }
    if(type==1)
        return mintall;
    return maxtall;
}
void pu(int inx)
{
    /// 1-> min
    /// 2-> max
    st[inx].mn=min(check(inx*2,1),check(inx*2+1,1));
    st[inx].mx=max(check(inx*2,2),check(inx*2+1,2));
}
void update(int l=1,int r=n,int inx=1)
{
    pull(inx,l,r);
    if(ul<=l&&r<=ur)
    {
        st[inx].lazy=val;
        pull(inx,l,r);
        return ;
    }
    if(l>ur||ul>r)
        return ;
    int mid=l+(r-l)/2;
    update(l,mid,inx*2);
    update(mid+1,r,inx*2+1);
    pu(inx);
}
int query(int pos,int l=1,int r=n,int inx=1)
{
    pull(inx,l,r);
    if(l==r)
    {
        if(st[inx].mn==st[inx].mx)
            return st[inx].mn;
        return -500;
    }
    int mid=l+(r-l)/2;
    if(pos<=mid)
        return query(pos,l,mid,inx*2);
    return query(pos,mid+1,r,inx*2+1);
}
void buildWall(int sz, int k, int op[], int left[], int right[],int height[], int finalHeight[])
{
    n=sz;
    FOR(i,k)
    {
        val=height[i];
        ul=left[i]+1;
        ur=right[i]+1;
        if(op[i]==1)
            add=1;
        else
            add=0;
        update();
    }
    FOR(i,n)
    finalHeight[i]=query(i+1);
}

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

wall.cpp: In function 'void pull(int, int, int)':
wall.cpp:19:20: error: 'max' was not declared in this scope; did you mean 'maxn'?
   19 |         st[inx].mn=max(st[inx].lazy,st[inx].mn);
      |                    ^~~
      |                    maxn
wall.cpp:29:20: error: 'min' was not declared in this scope
   29 |         st[inx].mx=min(st[inx].mx,st[inx].lazy);
      |                    ^~~
wall.cpp: In function 'int check(int, int)':
wall.cpp:47:21: error: 'max' was not declared in this scope; did you mean 'maxn'?
   47 |             mintall=max(st[inx].lazy,st[inx].mn);
      |                     ^~~
      |                     maxn
wall.cpp:52:21: error: 'min' was not declared in this scope
   52 |             maxtall=min(st[inx].mx,st[inx].lazy);
      |                     ^~~
wall.cpp: In function 'void pu(int)':
wall.cpp:64:16: error: 'min' was not declared in this scope
   64 |     st[inx].mn=min(check(inx*2,1),check(inx*2+1,1));
      |                ^~~
wall.cpp:65:16: error: 'max' was not declared in this scope; did you mean 'maxn'?
   65 |     st[inx].mx=max(check(inx*2,2),check(inx*2+1,2));
      |                ^~~
      |                maxn