답안 #969264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969264 2024-04-24T20:42:17 Z Hugo1729 벽 (IOI14_wall) C++11
8 / 100
3000 ms 13396 KB
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;

const int MAXN=100000*4;
int sz=1;
int a[MAXN],b[MAXN];

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

    b[2*v]=min(a[v*2],max(b[v],b[2*v]));
    b[2*v+1]=min(a[v*2+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);
    }
}

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);
    }
}


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]=100001;
        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;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 6 ms 2392 KB Output is correct
4 Correct 389 ms 2648 KB Output is correct
5 Correct 371 ms 2800 KB Output is correct
6 Correct 371 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 101 ms 13192 KB Output is correct
3 Execution timed out 3018 ms 7416 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 6 ms 2564 KB Output is correct
4 Correct 363 ms 2800 KB Output is correct
5 Correct 361 ms 2820 KB Output is correct
6 Correct 374 ms 2800 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 101 ms 13396 KB Output is correct
9 Execution timed out 3059 ms 7924 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 6 ms 2564 KB Output is correct
4 Correct 360 ms 2800 KB Output is correct
5 Correct 357 ms 2800 KB Output is correct
6 Correct 373 ms 2800 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 102 ms 13324 KB Output is correct
9 Execution timed out 3022 ms 7784 KB Time limit exceeded
10 Halted 0 ms 0 KB -