Submission #986880

# Submission time Handle Problem Language Result Execution time Memory
986880 2024-05-21T13:43:42 Z MuntherCarrot Wall (IOI14_wall) C++14
61 / 100
539 ms 32712 KB
#include <bits/stdc++.h>
#include "wall.h"

using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1 << 17;
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]);
    }
}

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

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++){
        upd(l[i], r[i], 1, 0, N - 1, h[i], op[i]);
    }
    pushall(1, 0, N - 1);
    for(int i = 0; i < n; i++){
        ans[i] = add[i + N];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 6 ms 3420 KB Output is correct
3 Correct 3 ms 3420 KB Output is correct
4 Correct 7 ms 3676 KB Output is correct
5 Correct 6 ms 3672 KB Output is correct
6 Correct 7 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 232 ms 11264 KB Output is correct
3 Correct 162 ms 8268 KB Output is correct
4 Correct 539 ms 17232 KB Output is correct
5 Correct 274 ms 18292 KB Output is correct
6 Correct 282 ms 17180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3416 KB Output is correct
2 Correct 4 ms 3420 KB Output is correct
3 Correct 3 ms 3420 KB Output is correct
4 Correct 6 ms 3676 KB Output is correct
5 Correct 6 ms 3676 KB Output is correct
6 Correct 6 ms 3676 KB Output is correct
7 Correct 3 ms 3420 KB Output is correct
8 Correct 290 ms 14776 KB Output is correct
9 Correct 163 ms 9096 KB Output is correct
10 Correct 448 ms 17288 KB Output is correct
11 Correct 312 ms 18308 KB Output is correct
12 Correct 271 ms 17280 KB Output is correct
13 Correct 2 ms 3420 KB Output is correct
14 Correct 264 ms 14668 KB Output is correct
15 Correct 27 ms 4432 KB Output is correct
16 Correct 461 ms 17548 KB Output is correct
17 Correct 273 ms 17188 KB Output is correct
18 Correct 284 ms 17540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 4 ms 3420 KB Output is correct
3 Correct 3 ms 3420 KB Output is correct
4 Correct 7 ms 3672 KB Output is correct
5 Correct 7 ms 3672 KB Output is correct
6 Correct 6 ms 3684 KB Output is correct
7 Correct 2 ms 3520 KB Output is correct
8 Correct 234 ms 14940 KB Output is correct
9 Correct 162 ms 9040 KB Output is correct
10 Correct 458 ms 17284 KB Output is correct
11 Correct 300 ms 18276 KB Output is correct
12 Correct 269 ms 17248 KB Output is correct
13 Correct 2 ms 3420 KB Output is correct
14 Correct 239 ms 14676 KB Output is correct
15 Correct 27 ms 4436 KB Output is correct
16 Correct 444 ms 17440 KB Output is correct
17 Correct 277 ms 17284 KB Output is correct
18 Correct 276 ms 17288 KB Output is correct
19 Runtime error 167 ms 32712 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -