Submission #853971

# Submission time Handle Problem Language Result Execution time Memory
853971 2023-09-25T17:33:52 Z thinknoexit Wall (IOI14_wall) C++17
24 / 100
444 ms 19796 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) {
        tree[now].mx = max(lazy[now].mx, tree[now].mx);
        tree[now].mn = 1e9;
        if (l != r) {
            // 2*now
            lazy[2 * now].mx = max(lazy[now].mx, lazy[2 * now].mx);
            ///2*now+1
            lazy[2 * now + 1].mx = max(lazy[now].mx, 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;
        }
        tree[now].mx = min(tree[now].mx, tree[now].mn);
        if (l != r) {
            // 2*now
            if (lazy[2 * now].mn >= lazy[now].mn) {
                lazy[2 * now].mn = lazy[now].mn;
            }
            lazy[2 * now].mx = min(lazy[2 * now].mx, lazy[2 * now].mn);
            //2*now+1
            if (lazy[2 * now + 1].mn >= lazy[now].mn) {
                lazy[2 * now + 1].mn = lazy[now].mn;
            }
            lazy[2 * now + 1].mx = min(lazy[2 * now + 1].mx, lazy[2 * now + 1].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];
    }
}

// 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
*/
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 101 ms 12120 KB Output is correct
3 Correct 134 ms 7760 KB Output is correct
4 Correct 444 ms 19440 KB Output is correct
5 Correct 213 ms 19796 KB Output is correct
6 Correct 212 ms 19792 KB Output is correct
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -