Submission #986891

# Submission time Handle Problem Language Result Execution time Memory
986891 2024-05-21T13:56:35 Z MuntherCarrot Wall (IOI14_wall) C++14
61 / 100
501 ms 47980 KB
#include <bits/stdc++.h>
#include "wall.h"

using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1 << 20;
int add[N << 2], del[N << 2];

void push(int i, int l, int r){
    if(l != r){
        add[i << 1] = min(add[i << 1], del[i]);
        add[i << 1] = max(add[i << 1], add[i]);
        del[i << 1] = min(del[i << 1], del[i]);
        del[i << 1] = max(del[i << 1], add[i]);
        add[i << 1 | 1] = min(add[i << 1 | 1], del[i]);
        add[i << 1 | 1] = max(add[i << 1 | 1], add[i]);
        del[i << 1 | 1] = min(del[i << 1 | 1], del[i]);
        del[i << 1 | 1] = max(del[i << 1 | 1], add[i]);
        add[i] = 0, del[i] = INF;
    }
}

void updAdd(int l, int r, int i, int from, int to, int val){
    push(i, from, to);
    if (from > r || to < l)
        return;
    if (from >= l && to <= r)
    {
        add[i] = max(add[i], val);
        del[i] = max(del[i], val);
        push(i, from, to);
        return;
    }
    int mid = (from + to) >> 1;
    updAdd(l, r, i << 1, from, mid, val);
    updAdd(l, r, i << 1 | 1, mid + 1, to, val);
}

void updDel(int l, int r, int i, int from, int to, int val){
    push(i, from, to);
    if(from > r || to < l) return;
    if(from >= l && to <= r){
        add[i] = min(add[i], val);
        del[i] = min(del[i], val);
        push(i, from, to);
        return;
    }
    int mid = (from + to) >> 1;
    updDel(l, r, i << 1, from, mid, val);
    updDel(l, r, i << 1 | 1, mid + 1, to , val);
}

void pushall(int i, int l, int r){
    if(l == r) return;
    push(i, l, r);
    int mid = (l + r) >> 1;
    pushall(i << 1, l, mid);
    pushall(i << 1 | 1, mid + 1, r);
}

void buildWall(int n, int k, int op[], int l[], int r[], int h[], int ans[]){
    memset(del, INF, sizeof del);
    for(int i = 0; i < k; i++){
        if(op[i] == 1){
            updAdd(l[i], r[i], 1, 0, N - 1, h[i]);
        }
        else{
            updDel(l[i], r[i], 1, 0, N - 1, h[i]);
        }
    }
    pushall(1, 0, N - 1);
    for(int i = 0; i < n; i++){
        ans[i] = min(add[i + N], del[i + N]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 25012 KB Output is correct
2 Correct 16 ms 24952 KB Output is correct
3 Correct 15 ms 24924 KB Output is correct
4 Correct 18 ms 25180 KB Output is correct
5 Correct 19 ms 25180 KB Output is correct
6 Correct 18 ms 25180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 24924 KB Output is correct
2 Correct 260 ms 32812 KB Output is correct
3 Correct 180 ms 28180 KB Output is correct
4 Correct 468 ms 33328 KB Output is correct
5 Correct 285 ms 33876 KB Output is correct
6 Correct 291 ms 33876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 24924 KB Output is correct
2 Correct 16 ms 25080 KB Output is correct
3 Correct 19 ms 24924 KB Output is correct
4 Correct 22 ms 25176 KB Output is correct
5 Correct 18 ms 25020 KB Output is correct
6 Correct 19 ms 25180 KB Output is correct
7 Correct 14 ms 24924 KB Output is correct
8 Correct 250 ms 32844 KB Output is correct
9 Correct 185 ms 28288 KB Output is correct
10 Correct 473 ms 33520 KB Output is correct
11 Correct 282 ms 33844 KB Output is correct
12 Correct 286 ms 33804 KB Output is correct
13 Correct 14 ms 24924 KB Output is correct
14 Correct 251 ms 32888 KB Output is correct
15 Correct 40 ms 25684 KB Output is correct
16 Correct 476 ms 33584 KB Output is correct
17 Correct 283 ms 33608 KB Output is correct
18 Correct 278 ms 33588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 24920 KB Output is correct
2 Correct 16 ms 24920 KB Output is correct
3 Correct 15 ms 25064 KB Output is correct
4 Correct 18 ms 25188 KB Output is correct
5 Correct 18 ms 25180 KB Output is correct
6 Correct 18 ms 25180 KB Output is correct
7 Correct 14 ms 24924 KB Output is correct
8 Correct 252 ms 32824 KB Output is correct
9 Correct 178 ms 28244 KB Output is correct
10 Correct 501 ms 33380 KB Output is correct
11 Correct 285 ms 33872 KB Output is correct
12 Correct 280 ms 33908 KB Output is correct
13 Correct 14 ms 24920 KB Output is correct
14 Correct 257 ms 32828 KB Output is correct
15 Correct 43 ms 25940 KB Output is correct
16 Correct 465 ms 33500 KB Output is correct
17 Correct 289 ms 33608 KB Output is correct
18 Correct 280 ms 33616 KB Output is correct
19 Incorrect 441 ms 47980 KB Output isn't correct
20 Halted 0 ms 0 KB -