답안 #1102103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102103 2024-10-17T12:42:35 Z alexander707070 벽 (IOI14_wall) C++14
100 / 100
516 ms 95428 KB
#include<bits/stdc++.h>
#include "wall.h"

#define MAXN 2000007
using namespace std;

int n,q;
int s[MAXN];

struct ST{
    struct node{
        int mins,maxs;
        int lazy;

        inline friend node operator + (node fr,node sc){
            return {min(fr.mins,sc.mins),max(fr.maxs,sc.maxs),-1};
        }
    };

    node tree[4*MAXN];

    void psh(int v){
        if(tree[v].lazy==-1)return;

        tree[2*v].maxs=tree[2*v].mins=tree[2*v].lazy=tree[v].lazy;
        tree[2*v+1].maxs=tree[2*v+1].mins=tree[2*v+1].lazy=tree[v].lazy;

        tree[v].lazy=-1;
    }

    void add(int v,int l,int r,int ll,int rr,int val){
        if(ll>rr)return;

        if(l==ll and r==rr and tree[v].maxs==tree[v].mins){
            if(tree[v].maxs<val){
                tree[v].maxs=tree[v].mins=val;
                tree[v].lazy=val;
            }
            return;
        }

        int tt=(l+r)/2;
        psh(v);

        add(2*v,l,tt,ll,min(tt,rr),val);
        add(2*v+1,tt+1,r,max(tt+1,ll),rr,val);

        tree[v]=tree[2*v]+tree[2*v+1];
    }

    void rem(int v,int l,int r,int ll,int rr,int val){
        if(ll>rr)return;

        if(l==ll and r==rr and tree[v].maxs==tree[v].mins){
            if(tree[v].maxs>val){
                tree[v].maxs=tree[v].mins=val;
                tree[v].lazy=val;
            }
            return;
        }

        int tt=(l+r)/2;
        psh(v);

        rem(2*v,l,tt,ll,min(tt,rr),val);
        rem(2*v+1,tt+1,r,max(tt+1,ll),rr,val);

        tree[v]=tree[2*v]+tree[2*v+1];
    }

    void solve(int v,int l,int r){
        if(l==r){
            s[l]=tree[v].maxs;
        }else{
            int tt=(l+r)/2;
            psh(v);

            solve(2*v,l,tt);
            solve(2*v+1,tt+1,r);
        }
    }
}seg;

void buildWall(int N, int K, int op[], int left[], int right[], int height[], int finalHeight[]){
//void buildWall(int N, int K, vector<int> op,vector<int> left, vector<int> right, vector<int> height){
    
    n=N; q=K;

    for(int i=0;i<q;i++){
        left[i]++;
        right[i]++;

        if(op[i]==1){
            seg.add(1,1,n,left[i],right[i],height[i]);
        }else{
            seg.rem(1,1,n,left[i],right[i],height[i]);
        }
    }

    seg.solve(1,1,n);

    for(int i=1;i<=n;i++){
        finalHeight[i-1]=s[i];
    }

    return;
}

/*int main(){

    buildWall(10,6,{1,2,2,1,1,2},{1,4,3,0,2,6},{8,9,6,5,2,7},{4,1,5,3,5,0});

	return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2640 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 6 ms 4944 KB Output is correct
5 Correct 4 ms 4808 KB Output is correct
6 Correct 4 ms 4944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 105 ms 16024 KB Output is correct
3 Correct 139 ms 11864 KB Output is correct
4 Correct 406 ms 24788 KB Output is correct
5 Correct 207 ms 25688 KB Output is correct
6 Correct 180 ms 24140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2400 KB Output is correct
3 Correct 2 ms 2400 KB Output is correct
4 Correct 6 ms 4960 KB Output is correct
5 Correct 4 ms 4952 KB Output is correct
6 Correct 4 ms 4952 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 91 ms 16112 KB Output is correct
9 Correct 147 ms 11856 KB Output is correct
10 Correct 398 ms 24656 KB Output is correct
11 Correct 190 ms 25672 KB Output is correct
12 Correct 174 ms 24084 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 96 ms 15920 KB Output is correct
15 Correct 30 ms 5712 KB Output is correct
16 Correct 498 ms 24996 KB Output is correct
17 Correct 197 ms 24396 KB Output is correct
18 Correct 188 ms 24552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2552 KB Output is correct
2 Correct 2 ms 2632 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 5 ms 4744 KB Output is correct
5 Correct 4 ms 4948 KB Output is correct
6 Correct 4 ms 4948 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 87 ms 16008 KB Output is correct
9 Correct 145 ms 11636 KB Output is correct
10 Correct 411 ms 24772 KB Output is correct
11 Correct 195 ms 25656 KB Output is correct
12 Correct 173 ms 24136 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 91 ms 15964 KB Output is correct
15 Correct 29 ms 5704 KB Output is correct
16 Correct 516 ms 24988 KB Output is correct
17 Correct 208 ms 24392 KB Output is correct
18 Correct 194 ms 24392 KB Output is correct
19 Correct 442 ms 95388 KB Output is correct
20 Correct 428 ms 92904 KB Output is correct
21 Correct 427 ms 95428 KB Output is correct
22 Correct 431 ms 93000 KB Output is correct
23 Correct 418 ms 92836 KB Output is correct
24 Correct 452 ms 92968 KB Output is correct
25 Correct 438 ms 92868 KB Output is correct
26 Correct 424 ms 95304 KB Output is correct
27 Correct 441 ms 95296 KB Output is correct
28 Correct 430 ms 93004 KB Output is correct
29 Correct 414 ms 93000 KB Output is correct
30 Correct 433 ms 93000 KB Output is correct