답안 #854244

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854244 2023-09-26T13:11:26 Z thinknoexit 벽 (IOI14_wall) C++17
24 / 100
470 ms 29692 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2000001;
struct A {
    int mx, mn;
} tree[4 * N], lazy[4 * N];
int n;
int ans[N];
void build(int now = 1, int l = 1, int r = n) {
    tree[now].mx = lazy[now].mx = 0;
    tree[now].mn = lazy[now].mn = 1e9;
    if (l == r) return;
    int mid = (l + r) / 2;
    build(2 * now, l, mid), build(2 * now + 1, mid + 1, r);
}
void lzy(int now, int l, int r) {
    if (lazy[now].mx != 0) {
        if (lazy[now].mx > tree[now].mx) {
            tree[now].mx = lazy[now].mx;
            tree[now].mn = 1e9;
        }
        if (l != r) {
            if (lazy[now].mx > lazy[2 * now].mx) {
                lazy[2 * now].mx = lazy[now].mx;
                lazy[2 * now].mn = 1e9;
            }
            if (lazy[now].mx > lazy[2 * now + 1].mx) {
                lazy[2 * now + 1].mx = lazy[now].mx;
                lazy[2 * now + 1].mn = 1e9;
            }
        }
        lazy[now].mx = 0;
    }
    if (lazy[now].mn != 1e9) {
        if (lazy[now].mn < tree[now].mx) {
            tree[now].mx = lazy[now].mn;
        }
        tree[now].mn = min(tree[now].mn, lazy[now].mn);
        if (l != r) {
            if (lazy[now].mn < lazy[2 * now].mx) {
                lazy[2 * now].mx = lazy[now].mn;
            }
            lazy[2 * now].mn = min(lazy[2 * now].mn, lazy[now].mn);
            if (lazy[now].mn < lazy[2 * now + 1].mx) {
                lazy[2 * now + 1].mx = lazy[now].mn;
            }
            lazy[2 * now + 1].mn = min(lazy[2 * now + 1].mn, lazy[now].mn);
        }
        lazy[now].mn = 1e9;
    }
}
void clear(int now = 1, int l = 1, int r = n) {
    lzy(now, l, r);
    if (l == r) {
        ans[l - 1] = tree[now].mx;
        return;
    }
    int mid = (l + r) / 2;
    clear(2 * now, l, mid), clear(2 * now + 1, mid + 1, r);
}
void update1(int ql, int qr, int v, int now = 1, int l = 1, int r = n) {
    lzy(now, l, r);
    if (l > qr || r < ql) return;
    if (ql <= l && r <= qr) {
        lazy[now].mx = v;
        lzy(now, l, r);
        return;
    }
    int mid = (l + r) / 2;
    update1(ql, qr, v, 2 * now, l, mid), update1(ql, qr, v, 2 * now + 1, mid + 1, r);
}
void update2(int ql, int qr, int v, int now = 1, int l = 1, int r = n) {
    lzy(now, l, r);
    if (l > qr || r < ql) return;
    if (ql <= l && r <= qr) {
        lazy[now].mn = v;
        lzy(now, l, r);
        return;
    }
    int mid = (l + r) / 2;
    update2(ql, qr, v, 2 * now, l, mid), update2(ql, qr, v, 2 * now + 1, mid + 1, r);
}
void buildWall(int NN, int k, int o[], int l[], int r[], int h[], int finalHeight[]) {
    n = NN;
    build();
    for (int i = 0;i < k;i++) {
        if (o[i] == 1) {
            update1(l[i] + 1, r[i] + 1, h[i]);
        }
        else {
            update2(l[i] + 1, r[i] + 1, h[i]);
        }
    }
    clear();
    for (int i = 0;i < n;i++) {
        finalHeight[i] = ans[i];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4440 KB Output is correct
3 Incorrect 2 ms 4548 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 114 ms 18136 KB Output is correct
3 Correct 171 ms 11604 KB Output is correct
4 Correct 470 ms 28656 KB Output is correct
5 Correct 251 ms 29692 KB Output is correct
6 Correct 232 ms 28020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Incorrect 2 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4552 KB Output is correct
3 Incorrect 3 ms 4440 KB Output isn't correct
4 Halted 0 ms 0 KB -