Submission #969273

# Submission time Handle Problem Language Result Execution time Memory
969273 2024-04-24T21:09:20 Z Hugo1729 Wall (IOI14_wall) C++11
0 / 100
129 ms 10168 KB
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;

const int MAXN=4194305;
int sz=1;
int a[MAXN],b[MAXN];

void push(int v){
    a[2*v]=min(a[v],a[2*v]);
    a[2*v+1]=min(a[v],a[2*v+1]);

    b[2*v]=max(b[v],b[2*v]);
    b[2*v+1]=max(b[v],b[2*v+1]);
}

void update1(int v, int tl, int tr, int l, int r, int val){
    if(l>r)return;
    if(tl==l&&tr==r){
        b[v]=min(a[v],max(b[v],val));
    }else{
        push(v);
        int mid=(tl+tr)/2;
        update1(v*2,tl,mid,l,min(mid,r),val);
        update1(v*2+1,mid+1,tr,max(mid+1,l),r,val);
        b[v]=min(b[v*2],b[v*2+1]);
    }
}

void update2(int v, int tl, int tr, int l, int r, int val){
    if(l>r)return;
    if(tl==l&&tr==r){
        a[v]=max(b[v],min(a[v],val));
    }else{
        push(v);
        int mid=(tl+tr)/2;
        update2(v*2,tl,mid,l,min(mid,r),val);
        update2(v*2+1,mid+1,tr,max(mid+1,l),r,val);
        a[v]=max(a[v*2],a[v*2+1]);
    }
}


void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    while(sz<n)sz<<=1;

    for(int i=1;i<2*sz;i++){
        a[i]=1000001;
        b[i]=0;
    }

    for(int i=k-1;i>=0;i--){
        if(op[i]==1)update1(1,1,sz,left[i]+1,right[i]+1,height[i]);
        else update2(1,1,sz,left[i]+1,right[i]+1,height[i]);

        // for(int i=1;i<sz;i++)push(i);
    }

    for(int i=0;i<n;i++)finalHeight[i]=b[i+sz];


    return;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Incorrect 3 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 102 ms 10168 KB Output is correct
3 Incorrect 129 ms 9900 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 3 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2572 KB Output is correct
3 Incorrect 2 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -