답안 #1016561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1016561 2024-07-08T08:10:03 Z vivkostov 벽 (IOI14_wall) C++14
0 / 100
82 ms 20108 KB
#include<bits/stdc++.h>
#include "wall.h"
#define endl '\n'
using namespace std;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n,k,type,le,ri,hi,otg[10000005],lazy[10000005],p[10000005],lazys[10000005];
void push_lazy(int h,int l,int r)
{
    if(lazys[h])
    {
        if(lazy[h*2]>lazys[h])
        {
            lazy[h*2]=lazys[h];
            p[h*2]=1;
        }
        if(lazy[h*2+1]>lazys[h])
        {
            lazy[h*2+1]=lazys[h];
            p[h*2]=1;
        }
        lazys[h]=0;
    }
    if(lazy[h]!=-1)
    {
        if(p[h]==1)
        {
            if(lazy[h]>lazy[h*2])
            {
                lazy[h*2]=lazy[h];
            }
            else if(p[h*2]==2)
            {
                lazys[h*2]=lazy[h*2];
                lazy[h*2]=lazy[h];
            }
            if(lazy[h]>lazy[h*2+1])
            {
                lazy[h*2+1]=lazy[h];
            }
            else if(p[h*2+1]==2)
            {
                lazys[h*2+1]=lazy[h*2+1];
                lazy[h*2+1]=lazy[h];
            }
            p[h*2]=1;
            p[h*2+1]=1;
        }
        else
        {
            if(lazy[h*2]==-1)
            {
                lazy[h*2]=lazy[h];
                p[h*2]=2;
            }
            if(lazy[h*2+1]==-1)
            {
                lazy[h*2+1]=lazy[h];
                p[h*2+1]=2;
            }
            if(lazy[h]<lazy[h*2])
            {
                lazy[h*2]=lazy[h];
                p[h*2]=1;
            }
            if(lazy[h]<lazy[h*2+1])
            {
                lazy[h*2+1]=lazy[h];
                p[h*2+1]=1;
            }
        }
        lazy[h]=-1;
        p[h]=0;
    }
}
void make_start(int l,int r,int h)
{
    if(l==r)return;
    lazy[h]=-1;
    int m=(l+r)/2;
    make_start(l,m,h*2);
    make_start(m+1,r,h*2+1);
}
void update(int l,int r,int ql,int qr,int h,int hi,int type)
{
    if(l>qr||r<ql)return;
    if(l!=r)push_lazy(h,l,r);
    if(l>=ql&&r<=qr)
    {
        lazy[h]=hi;
        p[h]=type;
        //cout<<l<<" "<<r<<" "<<lazy[h]<<endl;
        return;
    }
    //cout<<l<<" "<<r<<" "<<lazy[h]<<endl;
    int m=(l+r)/2;
    update(l,m,ql,qr,h*2,hi,type);
    update(m+1,r,ql,qr,h*2+1,hi,type);
}
void print(int l,int r,int h)
{
    if(l==r)
    {
        otg[l]=lazy[h];
        return;
    }
    //cout<<l<<" "<<r<<" "<<lazy[h]<<" "<<p[h]<<endl;
    push_lazy(h,l,r);
    //cout<<l<<" "<<r<<" "<<lazy[h]<<" "<<p[h]<<endl;
    //cout<<endl;
    int m=(l+r)/2;
    print(l,m,h*2);
    print(m+1,r,h*2+1);
}
void buildWall(int n, int k, int type[], int le[], int ri[], int hi[], int finalHeight[])
{
    make_start(1,n,1);
    for(int i=0;i<k;i++)
    {
        le[i]++;
        ri[i]++;
        update(1,n,le[i],ri[i],1,hi[i],type[i]);
    }
    print(1,n,1);
    for(int i=1;i<=n;i++)
    {
        finalHeight[i-1]=otg[i];
    }
}
void read()
{
    cin>>n>>k;
    make_start(1,n,1);
    for(int i=1;i<=k;i++)
    {
        cin>>type>>le>>ri>>hi;
        le++;
        ri++;
        //update(1,n,le,ri,1);
    }
    print(1,n,1);
    for(int i=1;i<=n;i++)
    {
        cout<<otg[i]<<" ";
    }
    cout<<endl;
}
/*int main()
{
    speed();
    read();
    return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Incorrect 2 ms 6488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 82 ms 20108 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Incorrect 2 ms 6492 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Incorrect 2 ms 6492 KB Output isn't correct
3 Halted 0 ms 0 KB -