답안 #853969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
853969 2023-09-25T17:25:29 Z thinknoexit 벽 (IOI14_wall) C++17
24 / 100
446 ms 19796 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2000001;
struct A {
    int mx, mn;
    int val() {
        return min(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) {
        tree[now].mx = max(lazy[now].mx, min(tree[now].mx, tree[now].mn));
        tree[now].mn = 1e9;
        if (l != r) {
            // 2*now
            lazy[2 * now].mx = max(lazy[now].mx, min(lazy[2 * now].mn, lazy[2 * now].mx));
            ///2*now+1
            lazy[2 * now + 1].mx = max(lazy[now].mx, min(lazy[2 * now + 1].mn, lazy[2 * now + 1].mx));
        }
        lazy[now].mx = 0;
    }
    if (lazy[now].mn != 1e9) {
        if (tree[now].mn >= lazy[now].mn) {
            tree[now].mn = lazy[now].mn;
        }
        if (l != r) {
            // 2*now
            if (lazy[2 * now].mn >= lazy[now].mn) {
                lazy[2 * now].mn = lazy[now].mn;
            }
            //2*now+1
            if (lazy[2 * now + 1].mn >= lazy[now].mn) {
                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].val();
        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];
    }
}

// int main() {
//     int n, k;
//     cin >> n >> k;
//     int O[k], L[k], R[k], V[k], ANS[n];
//     for (int i = 0;i < k;i++) {
//         cin >> O[i] >> L[i] >> R[i] >> V[i];
//     }
//     buildWall(n, k, O, L, R, V, ANS);
//     for (int i = 0;i < n;i++) {
//         cout << ANS[i] << ' ';
//     }
// }
/*
10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 2 5
2 6 7 0
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4440 KB Output is correct
3 Incorrect 2 ms 4440 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 112 ms 12624 KB Output is correct
3 Correct 149 ms 7856 KB Output is correct
4 Correct 446 ms 19548 KB Output is correct
5 Correct 213 ms 19796 KB Output is correct
6 Correct 209 ms 19548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4440 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 4440 KB Output is correct
2 Correct 2 ms 4440 KB Output is correct
3 Incorrect 2 ms 4440 KB Output isn't correct
4 Halted 0 ms 0 KB -