답안 #972842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972842 2024-05-01T09:01:25 Z sleepntsheep 벽 (IOI14_wall) C
0 / 100
777 ms 20056 KB
#include "wall.h"

#define MAX_N 2000002

int chmax[MAX_N<<2], chmin[MAX_N<<2], min[MAX_N<<2], max[MAX_N<<2];

void pull(int v)
{
    min[v]=min[v<<1|(min[v<<1]>min[v<<1|1])];
    max[v]=max[v<<1|(max[v<<1]<max[v<<1|1])];
}

void do_chmax(int v,int l,int r,int k)
{
    if(chmax[v]!=-1&&k<chmax[v])k=chmax[v];
    if(chmin[v]!=-1&&chmin[v]<=k)chmin[v]=-1;
    chmax[v]=k;
    if(k>=max[v])min[v]=max[v]=k;
    else if(k>=min[v])min[v]=k;
}

void do_chmin(int v,int l,int r,int k)
{
    if(chmin[v]!=-1&&k>chmin[v])k=chmin[v];
    if(chmax[v]!=-1&&chmax[v]>=k)chmax[v]=-1;
    chmin[v]=k;
    if(k<=min[v])min[v]=max[v]=k;
    else if(k<=max[v])max[v]=k;
}

void push(int v,int l,int r)
{
    if(chmin[v]!=-1)
    {
        if(l!=r) do_chmin(v<<1,l,l+(r-l)/2,chmin[v]),do_chmin(v<<1|1,l+(r-l)/2+1,r,chmin[v]);
        chmin[v]=-1;
    }
    if(chmax[v]!=-1)
    {
        if(l!=r) do_chmax(v<<1|1,l+(r-l)/2+1,r,chmax[v]),do_chmax(v<<1,l,l+(r-l)/2,chmax[v]);
        chmax[v]=-1;
    }
}

void do_do(int v,int l,int r,int x,int y,int k,void(*op)(int,int,int,int))
{
    push(v,l,r);
    if(r<x||y<l)return;
    if(x<=l&&r<=y){op(v,l,r,k);push(v,l,r);return ;}
    do_do(v<<1,l,l+(r-l)/2,x,y,k,op),do_do(v<<1|1,l+(r-l)/2+1,r,x,y,k,op);
    pull(v);
}

void build(int v,int l,int r)
{
    chmin[v]=chmax[v]=-1;
    if(l==r)min[v]=max[v]=0;
    else build(v<<1,l,l+(r-l)/2),build(v<<1|1,l+(r-l)/2+1,r),pull(v);
}

void ans(int v,int l,int r,int *o)
{
    push(v,l,r);
    if(l==r){o[l]=min[v];return;}
    ans(v<<1,l,l+(r-l)/2,o),ans(v<<1|1,l+(r-l)/2+1,r,o);
}

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]==2)do_do(1,0,n-1,left[i],right[i],height[i],do_chmin);
        else do_do(1,0,n-1,left[i],right[i],height[i],do_chmax);
    ans(1,0,n-1,finalHeight);
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 3 ms 6488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6580 KB Output is correct
2 Correct 109 ms 14388 KB Output is correct
3 Correct 259 ms 12104 KB Output is correct
4 Incorrect 777 ms 20056 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 3 ms 6492 KB Output is correct
3 Incorrect 3 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 3 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -