답안 #1012054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012054 2024-07-01T15:09:45 Z doducanh 벽 (IOI14_wall) C++14
0 / 100
72 ms 8276 KB
#include <bits/stdc++.h>

using namespace std;
#define lc (id<<1)
#define rc ((id<<1)|1)
#define ii pair<int,int>
#define fi first
#define se second
const int maxn=5e5+7;
const int inf=1e9+7;
int res[maxn];
struct segtree{
    int n;
    vector<int>t;
    vector<pair<int,int>>lazy;
    segtree(){}
    segtree(int n):n(n),t(n*3+7,0),lazy(n*3+7,{0,0}){}
    void pulldec(int x,int k)
    {
        t[x]=min(t[x],k);
        lazy[x].fi=min(lazy[x].fi,k);
        lazy[x].se=min(lazy[x].se,k);
    }
    void pulladd(int x,int k)
    {
        t[x]=max(t[x],k);
        lazy[x].fi=max(lazy[x].fi,k);
        lazy[x].se=max(lazy[x].se,k);
    }
    void down(int id){
        if(lazy[id].fi!=-inf){
            pulladd(lc,lazy[id].fi);
            pulladd(rc,lazy[id].fi);
        }
        if(lazy[id].se!=inf){
            pulldec(lc,lazy[id].se);
            pulldec(rc,lazy[id].se);
        }
        lazy[id]={-inf,inf};
    }
    void up(int id,int l,int r,int u,int v,int k,int type){
        if(l>v||r<u){
            return;
        }
        if(u<=l&&r<=v){
            if(type==1)pulladd(id,k);
            else pulldec(id,k);
            return;
        }
        if(l!=r)down(id);
        int m=(l+r)/2;
        up(lc,l,m,u,v,k,type);
        up(rc,m+1,r,u,v,k,type);
    }
    void get(int id,int l,int r){
        if(l==r){
            res[l]=t[id];
            return;
        }
        if(l!=r)down(id);
        int m=(l+r)/2;
        get(lc,l,m);
        get(rc,m+1,r);
    }
    void up(int u,int v,int k,int type){up(1,0,n-1,u,v,k,type);}
    void get(){get(1,0,n-1);}
};
int n,k;
int op[maxn],le[maxn],ri[maxn],height[maxn];
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[])
{
    segtree t(n);
    for(int i=0;i<k;i++){
        t.up(le[i],ri[i],height[i],op[i]);
    }
    t.get();
    for(int i=0;i<n;i++)finalHeight[i]=res[i];

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 72 ms 8276 KB Output is correct
3 Incorrect 52 ms 4432 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -