답안 #309906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309906 2020-10-05T00:49:17 Z thecodingwizard 벽 (IOI14_wall) C++11
100 / 100
1251 ms 62200 KB
#include <bits/stdc++.h>
using namespace std;
#include "wall.h"

struct node {
    int small = 0, large = 1e9;

    void upd(int op, int h) {
        if (op == 1) {
            // min
            small = max(small, h);
            large = max(large, h);
        } else {
            // max
            small = min(small, h);
            large = min(large, h);
        }
    }
};

node st[(1 << 22)];

void down(int p, int i, int j) {
    if (i == j) return;
    st[p*2].small = max(st[p].small, min(st[p*2].small, st[p].large));
    st[p*2].large = min(st[p].large, max(st[p*2].large, st[p].small));
    st[p*2+1].small = max(st[p].small, min(st[p*2+1].small, st[p].large));
    st[p*2+1].large = min(st[p].large, max(st[p*2+1].large, st[p].small));
    st[p].small = 0; st[p].large = 1e9;
}

void upd(int p, int i, int j, int l, int r, int op, int h) {
    down(p, i, j);
    if (i > r || j < l) return;
    if (l <= i && j <= r) {
        st[p].upd(op, h);
        return;
    }
    upd(p*2, i, (i+j)/2, l, r, op, h);
    upd(p*2+1, (i+j)/2+1, j, l, r, op, h);
}

int qry(int p, int i, int j, int x) {
    down(p, i, j);
    if (i == j && i == x) {
        return st[p].small;
    }
    if ((i+j)/2 >= x) return qry(p*2, i, (i+j)/2, x);
    return qry(p*2+1, (i+j)/2+1, j, x);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
    for (int i = 0; i < k; i++) {
        upd(1, 0, n-1, left[i], right[i], op[i], height[i]);
    }
    for (int i = 0; i < n; i++) {
        finalHeight[i] = qry(1, 0, n-1, i);
    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 9 ms 768 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 7 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 175 ms 8188 KB Output is correct
3 Correct 253 ms 4216 KB Output is correct
4 Correct 656 ms 10844 KB Output is correct
5 Correct 418 ms 11512 KB Output is correct
6 Correct 395 ms 11256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 9 ms 896 KB Output is correct
5 Correct 7 ms 768 KB Output is correct
6 Correct 8 ms 768 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 179 ms 8312 KB Output is correct
9 Correct 260 ms 4216 KB Output is correct
10 Correct 640 ms 10872 KB Output is correct
11 Correct 412 ms 11384 KB Output is correct
12 Correct 394 ms 11256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 180 ms 8184 KB Output is correct
15 Correct 41 ms 1528 KB Output is correct
16 Correct 731 ms 11128 KB Output is correct
17 Correct 408 ms 11128 KB Output is correct
18 Correct 409 ms 11128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 9 ms 768 KB Output is correct
5 Correct 9 ms 768 KB Output is correct
6 Correct 8 ms 768 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 178 ms 8184 KB Output is correct
9 Correct 259 ms 4216 KB Output is correct
10 Correct 641 ms 10852 KB Output is correct
11 Correct 417 ms 11384 KB Output is correct
12 Correct 401 ms 11256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 180 ms 8316 KB Output is correct
15 Correct 41 ms 1404 KB Output is correct
16 Correct 717 ms 11132 KB Output is correct
17 Correct 418 ms 11384 KB Output is correct
18 Correct 413 ms 11128 KB Output is correct
19 Correct 1239 ms 59384 KB Output is correct
20 Correct 1250 ms 59496 KB Output is correct
21 Correct 1231 ms 62176 KB Output is correct
22 Correct 1224 ms 59404 KB Output is correct
23 Correct 1213 ms 59640 KB Output is correct
24 Correct 1215 ms 59504 KB Output is correct
25 Correct 1223 ms 59512 KB Output is correct
26 Correct 1230 ms 61900 KB Output is correct
27 Correct 1226 ms 62200 KB Output is correct
28 Correct 1226 ms 59640 KB Output is correct
29 Correct 1251 ms 59512 KB Output is correct
30 Correct 1231 ms 59580 KB Output is correct