Submission #741619

# Submission time Handle Problem Language Result Execution time Memory
741619 2023-05-14T13:19:56 Z vjudge1 Wall (IOI14_wall) C++17
0 / 100
138 ms 14028 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()

struct Node {
    int mn = INT_MIN, mx = INT_MAX;
};

Node seg[2 * (1 << 21)];
int ans[2000005];

void lz(int k) {
    seg[k * 2].mn = min(seg[k * 2].mn, seg[k].mn);
    seg[k * 2].mn = max(seg[k * 2].mn, seg[k].mx);
    seg[k * 2].mx = min(seg[k * 2].mx, seg[k].mn);
    seg[k * 2].mx = max(seg[k * 2].mx, seg[k].mx);
    seg[k * 2 + 1].mn = min(seg[k * 2 + 1].mn, seg[k].mn);
    seg[k * 2 + 1].mn = max(seg[k * 2 + 1].mn, seg[k].mx);
    seg[k * 2 + 1].mx = min(seg[k * 2 + 1].mx, seg[k].mn);
    seg[k * 2 + 1].mx = max(seg[k * 2 + 1].mx, seg[k].mx);
}

void update(int k, int l, int r, int i, int j, int v, int t) {
    if (l > j || l < i) return;
    if (i <= l && r <= j) {
        if (t == 1) {
            seg[k].mn = max(seg[k].mn, v);
            seg[k].mx = max(seg[k].mx, v);
        }
        else {
            seg[k].mn = min(seg[k].mn, v);
            seg[k].mx = min(seg[k].mx, v);
        }
        return;
    }
    lz(k);
    seg[k].mn = INT_MAX;
    seg[k].mx = INT_MIN;
    update(k * 2, l, (l + r) / 2, i, j, v, t);
    update(k * 2 + 1, (l + r) / 2 + 1, r, i, j, v, t);
}

void get(int k, int l, int r) {
    if (l == r) {
        ans[l] = seg[k].mn;
        return;
    }
    lz(k);
    get(k * 2, l, (l + r) / 2);
    get(k * 2 + 1, (l + r) / 2 + 1, r);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
    for (int i = 0; i < k; i++) {
        update(1, 0, n - 1, left[i], right[i], height[i], op[i]);
    }
    get(1, 0, n - 1);
    for (int i = 0; i < n; i++) {
        finalHeight[i] = ans[i];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 138 ms 14028 KB Output is correct
3 Incorrect 65 ms 8016 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -