Submission #1032352

# Submission time Handle Problem Language Result Execution time Memory
1032352 2024-07-23T16:03:41 Z vjudge1 Wall (IOI14_wall) C++17
100 / 100
564 ms 138576 KB
#include "wall.h"

#include<bits/stdc++.h>
using namespace std;

const int lim=2e6+100;

struct{
    struct{
        int rem=0,add=0;
        int last=0;
    }tree[4*lim];
    int ans[lim]{};
    int n;
    void push(int node,int l,int r){
        if(l==r){
            if(tree[node].last){
                ans[l]=max(ans[l],tree[node].add);
                ans[l]=min(ans[l],tree[node].rem);
            }else{
                ans[l]=min(ans[l],tree[node].rem);
                ans[l]=max(ans[l],tree[node].add);
            }
        }else{
            int child=node<<1;
            if(tree[node].last){
                tree[child].rem=max(tree[child].rem,tree[node].add);
                tree[child].add=max(tree[child].add,tree[node].add);
                tree[child].rem=min(tree[child].rem,tree[node].rem);
                tree[child].add=min(tree[child].add,tree[node].rem);
            }else{
                tree[child].rem=min(tree[child].rem,tree[node].rem);
                tree[child].add=min(tree[child].add,tree[node].rem);
                tree[child].rem=max(tree[child].rem,tree[node].add);
                tree[child].add=max(tree[child].add,tree[node].add);
            }
            tree[child].last=tree[node].last;
            child++;
            if(tree[node].last){
                tree[child].rem=max(tree[child].rem,tree[node].add);
                tree[child].add=max(tree[child].add,tree[node].add);
                tree[child].rem=min(tree[child].rem,tree[node].rem);
                tree[child].add=min(tree[child].add,tree[node].rem);
            }else{
                tree[child].rem=min(tree[child].rem,tree[node].rem);
                tree[child].add=min(tree[child].add,tree[node].rem);
                tree[child].rem=max(tree[child].rem,tree[node].add);
                tree[child].add=max(tree[child].add,tree[node].add);
            }
            tree[child].last=tree[node].last;
        }
        tree[node].rem=200000;
        tree[node].add=0;
    }
    int L,R;
    int TY,VAL;
    void update(int l,int r,int node){
        if(r<L||R<l)return;
        push(node,l,r);
        if(L<=l&&r<=R){
            if(TY){
                tree[node].add=VAL;
            }else{
                tree[node].rem=VAL;
            }
            tree[node].last=TY;
            return;
        }
        int mid=(l+r)>>1,child=node<<1;
        update(l,mid,child),update(mid+1,r,child|1);
    }
    void update(int l,int r,int val,int ty){
        L=l,R=r,VAL=val,TY=ty;
        update(0,n-1,1);
    }
    void walk(int l,int r,int node){
        push(node,l,r);
        if(l==r)return;
        int mid=(l+r)>>1,child=node<<1;
        walk(l,mid,child),walk(mid+1,r,child|1);
    }
}st;

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    st.n=n;
    for(int i=0;i<k;i++){
        st.update(left[i],right[i],height[i],op[i]&1);
    }
    st.walk(0,n-1,1);
    for(int i=0;i<n;i++){
        finalHeight[i]=st.ans[i];
    }
}

# Verdict Execution time Memory Grader output
1 Correct 49 ms 101968 KB Output is correct
2 Correct 46 ms 102196 KB Output is correct
3 Correct 48 ms 102228 KB Output is correct
4 Correct 51 ms 102228 KB Output is correct
5 Correct 49 ms 102228 KB Output is correct
6 Correct 51 ms 102228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 101968 KB Output is correct
2 Correct 128 ms 115796 KB Output is correct
3 Correct 162 ms 109140 KB Output is correct
4 Correct 360 ms 120172 KB Output is correct
5 Correct 230 ms 121244 KB Output is correct
6 Correct 217 ms 119480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 101968 KB Output is correct
2 Correct 52 ms 102408 KB Output is correct
3 Correct 47 ms 102216 KB Output is correct
4 Correct 51 ms 102224 KB Output is correct
5 Correct 50 ms 102224 KB Output is correct
6 Correct 46 ms 102224 KB Output is correct
7 Correct 49 ms 101972 KB Output is correct
8 Correct 129 ms 115792 KB Output is correct
9 Correct 158 ms 109140 KB Output is correct
10 Correct 382 ms 120144 KB Output is correct
11 Correct 244 ms 121252 KB Output is correct
12 Correct 225 ms 119636 KB Output is correct
13 Correct 45 ms 101972 KB Output is correct
14 Correct 154 ms 115736 KB Output is correct
15 Correct 86 ms 103332 KB Output is correct
16 Correct 405 ms 120400 KB Output is correct
17 Correct 229 ms 119752 KB Output is correct
18 Correct 225 ms 119692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 101968 KB Output is correct
2 Correct 45 ms 102228 KB Output is correct
3 Correct 44 ms 102224 KB Output is correct
4 Correct 48 ms 102224 KB Output is correct
5 Correct 49 ms 102356 KB Output is correct
6 Correct 53 ms 102228 KB Output is correct
7 Correct 46 ms 102060 KB Output is correct
8 Correct 138 ms 115656 KB Output is correct
9 Correct 166 ms 109140 KB Output is correct
10 Correct 413 ms 120148 KB Output is correct
11 Correct 240 ms 121192 KB Output is correct
12 Correct 223 ms 119636 KB Output is correct
13 Correct 51 ms 102124 KB Output is correct
14 Correct 129 ms 115732 KB Output is correct
15 Correct 68 ms 103248 KB Output is correct
16 Correct 375 ms 120660 KB Output is correct
17 Correct 233 ms 119892 KB Output is correct
18 Correct 225 ms 119712 KB Output is correct
19 Correct 489 ms 138576 KB Output is correct
20 Correct 484 ms 136052 KB Output is correct
21 Correct 487 ms 138412 KB Output is correct
22 Correct 487 ms 136108 KB Output is correct
23 Correct 479 ms 136016 KB Output is correct
24 Correct 564 ms 136096 KB Output is correct
25 Correct 465 ms 136016 KB Output is correct
26 Correct 516 ms 138576 KB Output is correct
27 Correct 508 ms 138440 KB Output is correct
28 Correct 489 ms 136020 KB Output is correct
29 Correct 483 ms 136020 KB Output is correct
30 Correct 526 ms 136016 KB Output is correct