답안 #636949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636949 2022-08-30T16:18:27 Z PoonYaPat 벽 (IOI14_wall) C++14
100 / 100
792 ms 77396 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;

struct A {
    int mmax,mmin;
} lz[1<<22];

int ans[2000001];

void pushlz(int l, int r, int idx) {
    if (l!=r) {
        int u=2*idx, v=2*idx+1;

        lz[u].mmax=min(lz[idx].mmax,lz[u].mmax);
        lz[u].mmin=min(lz[idx].mmax,lz[u].mmin);
        lz[v].mmax=min(lz[idx].mmax,lz[v].mmax);
        lz[v].mmin=min(lz[idx].mmax,lz[v].mmin);
        lz[idx].mmax=INT_MAX;

        lz[u].mmax=max(lz[idx].mmin,lz[u].mmax);
        lz[u].mmin=max(lz[idx].mmin,lz[u].mmin);
        lz[v].mmax=max(lz[idx].mmin,lz[v].mmax);
        lz[v].mmin=max(lz[idx].mmin,lz[v].mmin);
        lz[idx].mmin=0;
    }
}

void update(int l, int r, int idx, int x, int y, int val, int mode) {
    pushlz(l,r,idx);
    if (x>r || y<l) return;
    if (x<=l && r<=y) {
        if (mode==1) {
            lz[idx].mmin=max(lz[idx].mmin,val);
            lz[idx].mmax=max(lz[idx].mmax,val);
        } else {
            lz[idx].mmax=min(lz[idx].mmax,val);
            lz[idx].mmin=min(lz[idx].mmin,val);
        }
    } else {
        int mid=(l+r)/2;
        update(l,mid,2*idx,x,y,val,mode);
        update(mid+1,r,2*idx+1,x,y,val,mode);
    }
}

void dfs(int l, int r, int idx) {
    pushlz(l,r,idx);
    if (l==r) {
        ans[l]=lz[idx].mmin;
    } else {
        int mid=(l+r)/2;
        dfs(l,mid,2*idx);
        dfs(mid+1,r,2*idx+1);
    }
}

void buildWall(int n, int k, int op[], int l[], int r[], int h[], int finalHeight[]){
    for (int i=1; i<=(1<<21); ++i) lz[i]={INT_MAX,0};
    for (int i=0; i<k; ++i) update(1,n,1,++l[i],++r[i],h[i],op[i]);
    dfs(1,n,1);
    for (int i=0; i<n; ++i) finalHeight[i]=ans[i+1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 16724 KB Output is correct
2 Correct 9 ms 16740 KB Output is correct
3 Correct 9 ms 16724 KB Output is correct
4 Correct 12 ms 16852 KB Output is correct
5 Correct 11 ms 16852 KB Output is correct
6 Correct 13 ms 16916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 16672 KB Output is correct
2 Correct 135 ms 24484 KB Output is correct
3 Correct 174 ms 20164 KB Output is correct
4 Correct 522 ms 25456 KB Output is correct
5 Correct 320 ms 26060 KB Output is correct
6 Correct 328 ms 26064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 16612 KB Output is correct
2 Correct 10 ms 16752 KB Output is correct
3 Correct 9 ms 16724 KB Output is correct
4 Correct 16 ms 16828 KB Output is correct
5 Correct 13 ms 16848 KB Output is correct
6 Correct 12 ms 16852 KB Output is correct
7 Correct 8 ms 16724 KB Output is correct
8 Correct 125 ms 24532 KB Output is correct
9 Correct 171 ms 20172 KB Output is correct
10 Correct 506 ms 25544 KB Output is correct
11 Correct 323 ms 26028 KB Output is correct
12 Correct 321 ms 26012 KB Output is correct
13 Correct 8 ms 16724 KB Output is correct
14 Correct 128 ms 24512 KB Output is correct
15 Correct 43 ms 17332 KB Output is correct
16 Correct 471 ms 25756 KB Output is correct
17 Correct 323 ms 25748 KB Output is correct
18 Correct 319 ms 25712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 16736 KB Output is correct
2 Correct 11 ms 16796 KB Output is correct
3 Correct 10 ms 16660 KB Output is correct
4 Correct 13 ms 16844 KB Output is correct
5 Correct 12 ms 16848 KB Output is correct
6 Correct 12 ms 16912 KB Output is correct
7 Correct 7 ms 16724 KB Output is correct
8 Correct 124 ms 24480 KB Output is correct
9 Correct 196 ms 20160 KB Output is correct
10 Correct 476 ms 25460 KB Output is correct
11 Correct 325 ms 26032 KB Output is correct
12 Correct 319 ms 26096 KB Output is correct
13 Correct 7 ms 16724 KB Output is correct
14 Correct 134 ms 24556 KB Output is correct
15 Correct 37 ms 17352 KB Output is correct
16 Correct 490 ms 25820 KB Output is correct
17 Correct 349 ms 25800 KB Output is correct
18 Correct 316 ms 25712 KB Output is correct
19 Correct 748 ms 66876 KB Output is correct
20 Correct 769 ms 74760 KB Output is correct
21 Correct 786 ms 77348 KB Output is correct
22 Correct 751 ms 74796 KB Output is correct
23 Correct 777 ms 74748 KB Output is correct
24 Correct 761 ms 74812 KB Output is correct
25 Correct 769 ms 74744 KB Output is correct
26 Correct 742 ms 77376 KB Output is correct
27 Correct 787 ms 77396 KB Output is correct
28 Correct 754 ms 74808 KB Output is correct
29 Correct 747 ms 74820 KB Output is correct
30 Correct 792 ms 74840 KB Output is correct