답안 #531115

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531115 2022-02-27T19:02:15 Z buidangnguyen05 벽 (IOI14_wall) C++14
100 / 100
949 ms 69468 KB
/* input

*/

#include "wall.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 2e6 + 10, inf = 2e9;
int ma[4 * N], mi[4 * N];

void build(int s, int l, int r) {
    ma[s] = 0; mi[s] = inf;
    if (l == r) return;
    int mid = (l + r) >> 1;
    build(s << 1, l, mid);
    build(s << 1 | 1, mid + 1, r);
}

void push(int s) {
    int par = s >> 1;
    if (mi[s] <= ma[par]) ma[s] = mi[s] = ma[par];
    else ma[s] = max(ma[s], ma[par]);
    mi[s] = min(mi[s], mi[par]);
}

void update(int s, int l, int r, int u, int v, int q, int val) {
    if (l > v || u > r) return;
    if (l >= u && r <= v) {
        if (q == 1) mi[s] = min(mi[s], val);
        else {
            if (mi[s] <= val) ma[s] = mi[s] = val;
            else ma[s] = max(ma[s], val);
        }
        return;
    }
    push(s << 1); push(s << 1 | 1);
    ma[s] = -inf; mi[s] = inf;
    int mid = (l + r) >> 1;
    update(s << 1, l, mid, u, v, q, val);
    update(s << 1 | 1, mid + 1, r, u, v, q, val);
}

int get(int s, int l, int r, int pos) {
    if (l == r) return min(ma[s], mi[s]);
    push(s << 1); push(s << 1 | 1);
    int mid = (l + r) >> 1;
    if (pos <= mid) return get(s << 1, l, mid, pos);
    return get(s << 1 | 1, mid + 1, r, pos);
}

void buildWall(int n, int m, int type[], int l[], int r[], int val[], int ans[]) {
    build(1, 1, n);

    for (int i = 0; i < m; ++i)  update(1, 1, n, l[i] + 1, r[i] + 1, type[i] - 1, val[i]);

    for (int i = 1; i <= n; ++i) ans[i - 1] = get(1, 1, n, i);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 6 ms 764 KB Output is correct
5 Correct 6 ms 824 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 117 ms 8532 KB Output is correct
3 Correct 143 ms 4744 KB Output is correct
4 Correct 354 ms 11196 KB Output is correct
5 Correct 260 ms 11744 KB Output is correct
6 Correct 247 ms 11740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 6 ms 748 KB Output is correct
5 Correct 5 ms 716 KB Output is correct
6 Correct 5 ms 716 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 116 ms 8556 KB Output is correct
9 Correct 147 ms 4752 KB Output is correct
10 Correct 352 ms 11184 KB Output is correct
11 Correct 255 ms 11796 KB Output is correct
12 Correct 246 ms 11684 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 120 ms 8556 KB Output is correct
15 Correct 27 ms 1956 KB Output is correct
16 Correct 441 ms 11520 KB Output is correct
17 Correct 249 ms 11484 KB Output is correct
18 Correct 250 ms 11492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 312 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 5 ms 716 KB Output is correct
6 Correct 6 ms 760 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 116 ms 8644 KB Output is correct
9 Correct 133 ms 4640 KB Output is correct
10 Correct 360 ms 11364 KB Output is correct
11 Correct 253 ms 11716 KB Output is correct
12 Correct 253 ms 11736 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 119 ms 8596 KB Output is correct
15 Correct 27 ms 1880 KB Output is correct
16 Correct 442 ms 11472 KB Output is correct
17 Correct 248 ms 11484 KB Output is correct
18 Correct 252 ms 11460 KB Output is correct
19 Correct 880 ms 59732 KB Output is correct
20 Correct 949 ms 67104 KB Output is correct
21 Correct 884 ms 69408 KB Output is correct
22 Correct 874 ms 66900 KB Output is correct
23 Correct 867 ms 66944 KB Output is correct
24 Correct 873 ms 66964 KB Output is correct
25 Correct 883 ms 66968 KB Output is correct
26 Correct 874 ms 69460 KB Output is correct
27 Correct 871 ms 69468 KB Output is correct
28 Correct 866 ms 66896 KB Output is correct
29 Correct 865 ms 67056 KB Output is correct
30 Correct 873 ms 67076 KB Output is correct