Submission #757377

# Submission time Handle Problem Language Result Execution time Memory
757377 2023-06-13T06:35:38 Z lucri Wall (IOI14_wall) C++17
0 / 100
231 ms 13988 KB
#include <bits/stdc++.h>

#include "wall.h"

struct arboreintervale{int val,lazy,lim;}aint[8000010];
void propaga(int poz,int b,int e)
{
    if(aint[poz].lazy>aint[poz].lim)
        aint[poz].lazy=aint[poz].lim;
    if(b==e)
        aint[poz].val=aint[poz].lazy;
    else
    {
        if(aint[poz].lazy>=aint[poz*2].lazy||aint[poz].lazy>=aint[poz*2].lim)
        {
            aint[poz*2].lazy=aint[poz].lazy;
            aint[poz*2].lim=std::min(aint[poz*2].lim,aint[poz].lim);
            if(aint[poz*2].lim<aint[poz*2].lazy)
                aint[poz*2].lim=aint[poz*2].lazy;
        }
        else
            aint[poz*2].lim=std::min(aint[poz*2].lim,aint[poz].lim);
        if(aint[poz].lazy>=aint[poz*2+1].lazy||aint[poz].lazy>=aint[poz*2+1].lim)
        {
            aint[poz*2+1].lazy=aint[poz].lazy;
            aint[poz*2+1].lim=std::min(aint[poz*2+1].lim,aint[poz].lim);
            if(aint[poz*2+1].lim<aint[poz*2+1].lazy)
                aint[poz*2+1].lim=aint[poz*2+1].lazy;
        }
        else
            aint[poz*2+1].lim=std::min(aint[poz*2+1].lim,aint[poz].lim);
        aint[poz].lim=2000000010;
        aint[poz].lazy=0;
    }
}
void atribuie(int poz,int b,int e,int bi,int ei,int val)
{
    propaga(poz,b,e);
    if(e<bi||ei<b)
        return;
    if(bi<=b&&e<=ei)
    {
        aint[poz].lazy=val;
        aint[poz].lim=2000000010;
        return;
    }
    atribuie(poz*2,b,(b+e)/2,bi,ei,val);
    atribuie(poz*2+1,(b+e)/2+1,e,bi,ei,val);
}
void limiteaza(int poz,int b,int e,int bi,int ei,int val)
{
    if(e<bi||ei<b)
    {
        propaga(poz,b,e);
        return;
    }
    if(bi<=b&&e<=ei)
    {
        aint[poz].lim=std::min(val,aint[poz].lim);
        propaga(poz,b,e);
        return;
    }
    propaga(poz,b,e);
    limiteaza(poz*2,b,(b+e)/2,bi,ei,val);
    limiteaza(poz*2+1,(b+e)/2+1,e,bi,ei,val);
}
int pozac;
void finalans(int poz,int b,int e,int ans[])
{
    propaga(poz,b,e);
    if(b==e)
    {
        ans[pozac++]=aint[poz].val;
        return;
    }
    finalans(poz*2,b,(b+e)/2,ans);
    finalans(poz*2+1,(b+e)/2+1,e,ans);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
    aint[1].lim=2000000010;
    for(int i=0;i<k;++i)
    {
        ++left[i];
        ++right[i];
        if(op[i]==1)
            atribuie(1,1,n,left[i],right[i],height[i]);
        else
            limiteaza(1,1,n,left[i],right[i],height[i]);
    }
    finalans(1,1,n,finalHeight);
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 448 KB Output is correct
3 Incorrect 2 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 133 ms 13988 KB Output is correct
3 Incorrect 231 ms 8268 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Incorrect 2 ms 320 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
3 Incorrect 3 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -