Submission #853951

# Submission time Handle Problem Language Result Execution time Memory
853951 2023-09-25T16:45:19 Z thinknoexit Wall (IOI14_wall) C++17
24 / 100
477 ms 29780 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) {
        if (min(tree[now].mx, tree[now].mn) <= lazy[now].mx) {
            tree[now].mx = lazy[now].mx;
        }
        tree[now].mn = 1e9;
        if (l != r) {
            // 2*now
            if (min(lazy[2 * now].mn, lazy[2 * now].mx) <= lazy[now].mx) {
                lazy[2 * now].mx = lazy[now].mx;
            }
            lazy[2 * now].mn = 1e9;
            ///2*now+1
            if (min(lazy[2 * now + 1].mn, lazy[2 * now + 1].mx) <= lazy[now].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 (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
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4548 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 4444 KB Output is correct
2 Correct 113 ms 18120 KB Output is correct
3 Correct 181 ms 11604 KB Output is correct
4 Correct 477 ms 28900 KB Output is correct
5 Correct 241 ms 29780 KB Output is correct
6 Correct 222 ms 28320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4676 KB Output is correct
3 Incorrect 2 ms 4548 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4600 KB Output is correct
3 Incorrect 2 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -