Submission #757598

# Submission time Handle Problem Language Result Execution time Memory
757598 2023-06-13T12:16:49 Z lucri Wall (IOI14_wall) C++17
100 / 100
777 ms 86080 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)
    {
        if(b!=e||aint[poz].lazy<val)
        {
            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)
{
    propaga(poz,b,e);
    if(e<bi||ei<b)
        return;
    if(bi<=b&&e<=ei)
    {
        aint[poz].lim=val;
        return;
    }
    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 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 7 ms 964 KB Output is correct
5 Correct 5 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 123 ms 8140 KB Output is correct
3 Correct 216 ms 4408 KB Output is correct
4 Correct 516 ms 21340 KB Output is correct
5 Correct 327 ms 22400 KB Output is correct
6 Correct 327 ms 20848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 7 ms 852 KB Output is correct
5 Correct 5 ms 852 KB Output is correct
6 Correct 8 ms 872 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 143 ms 13912 KB Output is correct
9 Correct 214 ms 8268 KB Output is correct
10 Correct 507 ms 21428 KB Output is correct
11 Correct 334 ms 22456 KB Output is correct
12 Correct 314 ms 20868 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 132 ms 13952 KB Output is correct
15 Correct 38 ms 2252 KB Output is correct
16 Correct 675 ms 21592 KB Output is correct
17 Correct 340 ms 21096 KB Output is correct
18 Correct 336 ms 21000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 7 ms 960 KB Output is correct
5 Correct 6 ms 896 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 131 ms 13856 KB Output is correct
9 Correct 222 ms 8272 KB Output is correct
10 Correct 531 ms 21352 KB Output is correct
11 Correct 329 ms 22348 KB Output is correct
12 Correct 331 ms 20836 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 134 ms 13868 KB Output is correct
15 Correct 37 ms 2248 KB Output is correct
16 Correct 653 ms 21580 KB Output is correct
17 Correct 349 ms 21016 KB Output is correct
18 Correct 338 ms 21176 KB Output is correct
19 Correct 744 ms 85904 KB Output is correct
20 Correct 759 ms 83424 KB Output is correct
21 Correct 769 ms 85932 KB Output is correct
22 Correct 777 ms 83552 KB Output is correct
23 Correct 762 ms 83416 KB Output is correct
24 Correct 773 ms 83400 KB Output is correct
25 Correct 765 ms 83332 KB Output is correct
26 Correct 762 ms 86076 KB Output is correct
27 Correct 775 ms 86080 KB Output is correct
28 Correct 761 ms 83404 KB Output is correct
29 Correct 750 ms 83508 KB Output is correct
30 Correct 749 ms 83432 KB Output is correct