답안 #305071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305071 2020-09-22T14:07:06 Z vipghn2003 벽 (IOI14_wall) C++14
100 / 100
1451 ms 99960 KB
#include<bits/stdc++.h>

using namespace std;
const int N=2e6+5;
int STmn[4*N],STmx[4*N],lazymin[4*N],lazymax[4*N],res[N];

void build(int id,int l,int r)
{
    lazymin[id]=1e9;
    lazymax[id]=0;
    if(l==r) return ;
    int mid=(l+r)/2;
    build(id*2,l,mid);
    build(id*2+1,mid+1,r);
}

void dolazy(int id,int l,int r)
{
    STmn[id]=min(STmn[id],lazymin[id]);
    STmn[id]=max(STmn[id],lazymax[id]);
    STmx[id]=min(STmx[id],lazymin[id]);
    STmx[id]=max(STmx[id],lazymax[id]);
    if(l!=r)
    {
        lazymin[id*2]=min(lazymin[id*2],lazymin[id]);
        lazymin[id*2+1]=min(lazymin[id*2+1],lazymin[id]);
        lazymin[id*2]=max(lazymin[id*2],lazymax[id]);
        lazymin[id*2+1]=max(lazymin[id*2+1],lazymax[id]);
        lazymax[id*2+1]=min(lazymax[id*2+1],lazymin[id]);
        lazymax[id*2]=min(lazymax[id*2],lazymin[id]);
        lazymax[id*2+1]=max(lazymax[id*2+1],lazymax[id]);
        lazymax[id*2]=max(lazymax[id*2],lazymax[id]);
    }
    lazymax[id]=0;
    lazymin[id]=1e9;
}

void update(int id,int l,int r,int L,int R,int type,int val)
{
    dolazy(id,l,r);
    if(R<l||r<L) return;
    if(L<=l&&r<=R)
    {
        if(type==1)
        {
            lazymin[id]=max(lazymin[id],val);
            lazymax[id]=max(lazymax[id],val);
        }
        else if(type==2)
        {
            lazymin[id]=min(lazymin[id],val);
            lazymax[id]=min(lazymax[id],val);
        }
        dolazy(id,l,r);
        return;
    }
    int mid=(l+r)/2;
    update(id*2,l,mid,L,R,type,val);
    update(id*2+1,mid+1,r,L,R,type,val);
    STmx[id]=max(STmx[id*2],STmx[id*2+1]);
    STmn[id]=min(STmn[id*2],STmn[id*2+1]);
}

void comp(int id, int l, int r)
{
    dolazy(id,l,r);
    if(l==r)
    {
        res[l]=STmn[id];
        return;
    }
    int mid=(l+r)/2;
    comp(id*2,l,mid);
    comp(id*2+1,mid+1,r);
}

void buildWall(int n,int k,int op[],int left[],int right[],int height[],int finalHeight[])
{
    build(1,1,n);
    for(int i=0;i<k;i++) update(1,1,n,left[i]+1,right[i]+1,op[i],height[i]);
    comp(1,1,n);
    for(int i=0;i<n;i++) finalHeight[i]=res[i+1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 10 ms 1024 KB Output is correct
5 Correct 9 ms 1024 KB Output is correct
6 Correct 9 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 171 ms 8184 KB Output is correct
3 Correct 331 ms 4860 KB Output is correct
4 Correct 1025 ms 13264 KB Output is correct
5 Correct 567 ms 13816 KB Output is correct
6 Correct 561 ms 13816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 10 ms 1024 KB Output is correct
5 Correct 8 ms 1024 KB Output is correct
6 Correct 9 ms 1024 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 175 ms 8312 KB Output is correct
9 Correct 341 ms 4876 KB Output is correct
10 Correct 1022 ms 13308 KB Output is correct
11 Correct 561 ms 13944 KB Output is correct
12 Correct 549 ms 13944 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 176 ms 8184 KB Output is correct
15 Correct 55 ms 2168 KB Output is correct
16 Correct 1048 ms 13816 KB Output is correct
17 Correct 548 ms 13516 KB Output is correct
18 Correct 551 ms 13560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 10 ms 1024 KB Output is correct
5 Correct 9 ms 1024 KB Output is correct
6 Correct 8 ms 1024 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 174 ms 8184 KB Output is correct
9 Correct 333 ms 4984 KB Output is correct
10 Correct 1031 ms 13432 KB Output is correct
11 Correct 550 ms 13816 KB Output is correct
12 Correct 545 ms 13772 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 173 ms 8312 KB Output is correct
15 Correct 52 ms 2040 KB Output is correct
16 Correct 1050 ms 13656 KB Output is correct
17 Correct 551 ms 13560 KB Output is correct
18 Correct 550 ms 13560 KB Output is correct
19 Correct 1418 ms 99832 KB Output is correct
20 Correct 1418 ms 97384 KB Output is correct
21 Correct 1423 ms 99960 KB Output is correct
22 Correct 1418 ms 97528 KB Output is correct
23 Correct 1410 ms 97400 KB Output is correct
24 Correct 1413 ms 97400 KB Output is correct
25 Correct 1408 ms 97272 KB Output is correct
26 Correct 1438 ms 99960 KB Output is correct
27 Correct 1434 ms 99960 KB Output is correct
28 Correct 1451 ms 97272 KB Output is correct
29 Correct 1426 ms 97400 KB Output is correct
30 Correct 1424 ms 97384 KB Output is correct