답안 #1062366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062366 2024-08-17T04:22:17 Z Vedant18 벽 (IOI14_wall) C++14
100 / 100
431 ms 69632 KB
#include<bits/stdc++.h>
using namespace std;

struct node{
    int lowrbnd=0;
    int upprbnd=1e6;
};

vector<node>sgt(1<<22);
void push(int v){
    auto upd=[&](int &ind){
        ind=min(ind,sgt[v].upprbnd);
        ind=max(ind,sgt[v].lowrbnd); 
    };
        upd(sgt[2*v].upprbnd);
        upd(sgt[2*v].lowrbnd);
        upd(sgt[2*v+1].lowrbnd);
        upd(sgt[2*v+1].upprbnd);
        sgt[v]=node();
}
void build(int v,int tl, int tr){
    if(tl==tr){
        sgt[v].lowrbnd=0;
        sgt[v].upprbnd=0;
    }
    else{
        int tm=(tl+tr)/2;
        build(2*v,tl,tm);
        build(2*v+1,tm+1,tr);
    }
}
void upd_rng(int v, int tl, int tr, int l, int r, int typ, int val){
    if(l>r){
        return ;
    }
    if(tl==l&&tr==r){
        if(typ==1){
            //max with-> lowerbound update
            sgt[v].lowrbnd=max(val,sgt[v].lowrbnd);
            sgt[v].upprbnd=max(val,sgt[v].upprbnd);
        }
        else{
            //upper bound
            sgt[v].lowrbnd=min(val,sgt[v].lowrbnd);
            sgt[v].upprbnd=min(val,sgt[v].upprbnd);
        }
    }
    else{
        push(v);
        int tm=(tl+tr)/2;
        upd_rng(2*v,tl,tm,l,min(r,tm),typ,val);
        upd_rng(2*v+1,tm+1,tr,max(tm+1,l),r,typ,val);
    }
}
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){
    int N=(1<<21)-1;
    build(1,0,N);
    for(int i=0;i<k;i++){
        upd_rng(1,0,N,left[i],right[i],op[i],height[i]);
    }
    for(int v=1;v<(1<<21);v++){
        push(v);
    }
    for(int i=0;i<n;i++){
        finalHeight[i]=sgt[i+(1<<21)].lowrbnd;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 33116 KB Output is correct
2 Correct 25 ms 33372 KB Output is correct
3 Correct 19 ms 33116 KB Output is correct
4 Correct 21 ms 33372 KB Output is correct
5 Correct 20 ms 33480 KB Output is correct
6 Correct 22 ms 33372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 33116 KB Output is correct
2 Correct 200 ms 46920 KB Output is correct
3 Correct 134 ms 40276 KB Output is correct
4 Correct 329 ms 51284 KB Output is correct
5 Correct 229 ms 52160 KB Output is correct
6 Correct 225 ms 50700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 33112 KB Output is correct
2 Correct 20 ms 33372 KB Output is correct
3 Correct 19 ms 33116 KB Output is correct
4 Correct 20 ms 33292 KB Output is correct
5 Correct 20 ms 33476 KB Output is correct
6 Correct 20 ms 33372 KB Output is correct
7 Correct 17 ms 33116 KB Output is correct
8 Correct 210 ms 47160 KB Output is correct
9 Correct 132 ms 40272 KB Output is correct
10 Correct 318 ms 51280 KB Output is correct
11 Correct 222 ms 52308 KB Output is correct
12 Correct 222 ms 50752 KB Output is correct
13 Correct 17 ms 33280 KB Output is correct
14 Correct 213 ms 46672 KB Output is correct
15 Correct 35 ms 34336 KB Output is correct
16 Correct 317 ms 51540 KB Output is correct
17 Correct 222 ms 50768 KB Output is correct
18 Correct 221 ms 50968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 33116 KB Output is correct
2 Correct 19 ms 33372 KB Output is correct
3 Correct 18 ms 33344 KB Output is correct
4 Correct 20 ms 33488 KB Output is correct
5 Correct 20 ms 33372 KB Output is correct
6 Correct 24 ms 33372 KB Output is correct
7 Correct 17 ms 33116 KB Output is correct
8 Correct 212 ms 46732 KB Output is correct
9 Correct 134 ms 40276 KB Output is correct
10 Correct 313 ms 51280 KB Output is correct
11 Correct 219 ms 52308 KB Output is correct
12 Correct 225 ms 50772 KB Output is correct
13 Correct 17 ms 33112 KB Output is correct
14 Correct 213 ms 46676 KB Output is correct
15 Correct 36 ms 34388 KB Output is correct
16 Correct 334 ms 51540 KB Output is correct
17 Correct 225 ms 50772 KB Output is correct
18 Correct 222 ms 50928 KB Output is correct
19 Correct 403 ms 69460 KB Output is correct
20 Correct 422 ms 67156 KB Output is correct
21 Correct 411 ms 69460 KB Output is correct
22 Correct 402 ms 67112 KB Output is correct
23 Correct 406 ms 67092 KB Output is correct
24 Correct 402 ms 67156 KB Output is correct
25 Correct 406 ms 67140 KB Output is correct
26 Correct 426 ms 69632 KB Output is correct
27 Correct 407 ms 69460 KB Output is correct
28 Correct 431 ms 67156 KB Output is correct
29 Correct 416 ms 66988 KB Output is correct
30 Correct 426 ms 67156 KB Output is correct