답안 #725713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725713 2023-04-17T23:47:32 Z Abrar_Al_Samit 벽 (IOI14_wall) C++17
100 / 100
877 ms 99356 KB
#include <bits/stdc++.h>
using namespace std;
#include "wall.h"

const int INF = 1e9;
const int nax = 2e6 + 3;

pair<int, int>st[nax * 4];


void propagate(int v) {
    for(int c : {v*2, v*2+1}) {
        st[c].first = max(st[v].first, st[c].first);
        st[c].second = max(st[c].first, st[c].second);

        st[c].second = min(st[c].second, st[v].second);
        st[c].first = min(st[c].first, st[c].second);
    }
    st[v] = {-INF, INF};
}
void maximize(int l, int r, int L, int R, int val, int v) {
    if(l>R || r<L) return;
    if(l>=L && r<=R) {
        st[v].first = max(st[v].first, val);
        st[v].second = max(st[v].first, st[v].second);
        return;
    }
    propagate(v);
    int mid = (l+r)/2;
    maximize(l, mid, L, R, val, v*2);
    maximize(mid+1, r, L, R, val, v*2+1);
}
void minimize(int l, int r, int L, int R, int val, int v) {
    if(l>R || r<L) return;
    if(l>=L && r<=R) {
        st[v].second = min(st[v].second, val);
        st[v].first = min(st[v].first, st[v].second);
        return;
    }
    propagate(v);
    int mid = (l+r)/2;
    minimize(l, mid, L, R, val, v*2);
    minimize(mid+1, r, L, R, val, v*2+1);   
}
int query(int l, int r, int p, int v) {
    if(l==r) {
        return min(max(0, st[v].first), st[v].second);
    }
    propagate(v);
    int mid = (l+r)/2;
    if(p<=mid) return query(l, mid, p, v*2);
    else return query(mid+1, r, p, v*2+1);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    for(int i=1; i<nax * 4; ++i) {
        st[i] = {-INF, INF};
    }
    for(int i=0; i<k; ++i) {
        if(op[i]==1) {
            maximize(1, n, left[i]+1, right[i]+1, height[i], 1);
        } else {
            minimize(1, n, left[i]+1, right[i]+1, height[i], 1);
        }
    }
    for(int i=0; i<n; ++i) {
        finalHeight[i] = query(1, n, i+1, 1);
    }
    return;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 62892 KB Output is correct
2 Correct 29 ms 62996 KB Output is correct
3 Correct 31 ms 62964 KB Output is correct
4 Correct 34 ms 63068 KB Output is correct
5 Correct 36 ms 63148 KB Output is correct
6 Correct 33 ms 63080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 62792 KB Output is correct
2 Correct 165 ms 70992 KB Output is correct
3 Correct 154 ms 66480 KB Output is correct
4 Correct 396 ms 71552 KB Output is correct
5 Correct 277 ms 72160 KB Output is correct
6 Correct 283 ms 72140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 62808 KB Output is correct
2 Correct 30 ms 63016 KB Output is correct
3 Correct 30 ms 62924 KB Output is correct
4 Correct 37 ms 63136 KB Output is correct
5 Correct 33 ms 63112 KB Output is correct
6 Correct 35 ms 63052 KB Output is correct
7 Correct 30 ms 62796 KB Output is correct
8 Correct 161 ms 71000 KB Output is correct
9 Correct 163 ms 66548 KB Output is correct
10 Correct 382 ms 71744 KB Output is correct
11 Correct 282 ms 72008 KB Output is correct
12 Correct 279 ms 72032 KB Output is correct
13 Correct 28 ms 62800 KB Output is correct
14 Correct 160 ms 70980 KB Output is correct
15 Correct 51 ms 63660 KB Output is correct
16 Correct 390 ms 72672 KB Output is correct
17 Correct 277 ms 72660 KB Output is correct
18 Correct 277 ms 72652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 62796 KB Output is correct
2 Correct 32 ms 62972 KB Output is correct
3 Correct 30 ms 62944 KB Output is correct
4 Correct 34 ms 63152 KB Output is correct
5 Correct 32 ms 63104 KB Output is correct
6 Correct 33 ms 63052 KB Output is correct
7 Correct 30 ms 62844 KB Output is correct
8 Correct 164 ms 70932 KB Output is correct
9 Correct 166 ms 66444 KB Output is correct
10 Correct 387 ms 71520 KB Output is correct
11 Correct 289 ms 72076 KB Output is correct
12 Correct 272 ms 72012 KB Output is correct
13 Correct 28 ms 62848 KB Output is correct
14 Correct 165 ms 70852 KB Output is correct
15 Correct 51 ms 63560 KB Output is correct
16 Correct 380 ms 72776 KB Output is correct
17 Correct 285 ms 72712 KB Output is correct
18 Correct 291 ms 72624 KB Output is correct
19 Correct 865 ms 89964 KB Output is correct
20 Correct 860 ms 96840 KB Output is correct
21 Correct 871 ms 99272 KB Output is correct
22 Correct 864 ms 96700 KB Output is correct
23 Correct 862 ms 96872 KB Output is correct
24 Correct 862 ms 96808 KB Output is correct
25 Correct 866 ms 96700 KB Output is correct
26 Correct 874 ms 99356 KB Output is correct
27 Correct 874 ms 99248 KB Output is correct
28 Correct 877 ms 96752 KB Output is correct
29 Correct 872 ms 96876 KB Output is correct
30 Correct 858 ms 96708 KB Output is correct