Submission #1043379

# Submission time Handle Problem Language Result Execution time Memory
1043379 2024-08-04T08:58:10 Z deera Wall (IOI14_wall) C++14
Compilation error
0 ms 0 KB
// ioi 2014
// Day 2: Wall
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;

// {low, high}
vector<vector<int>> tree;

struct Op {
    int t, v;
};

void push(int x, int l, int r) {
    if (l == r) return;

    x *= 2;
    laze(x, {1, tree[x][0]});
    laze(x, {2, tree[x][1]});
    laze(x + 1, {1, tree[x][0]});
    laze(x + 1, {2, tree[x][1]});

    tree[x/2] = {0, INT_MAX};
}

void laze(int x, Op op) {
    if (op.t == 1) {
        tree[x][0] = max(tree[x][0], op.v);
        tree[x][1] = max(tree[x][1], tree[x][0]);
    } else {
        tree[x][0] = min(tree[x][0], tree[x][1]);
        tree[x][1] = min(tree[x][1], op.v);
    }
}

void output(int x, int l, int r, int results[]) {
    if (l == r) {
        results[l] == tree[x][0];
        return;
    }

    push(x, l, r);

    int m = (l + r) / 2;
    x *= 2;
    output(x, l, m, results);
    output(x + 1, m + 1, r, results);
}

void update(int x, int l, int r, int a, int b, Op op) {
    if (r < a || b , l) return;
    if (a <= l && r <= b) return laze(x, op);

    push(x, l, r);
    
    int m = (l + r) / 2;
    x *= 2;
    update(x, l, m, a, b, op);
    update(x + 1, m + 1, r, a, b, op);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    // // subtask 1
    // if (n <= 10000 && k <= 5000) {
    //     for (int i = 0; i < k; i++) {
    //         if (op[i] == 1) {
    //             for (int j = left[i]; j <= right[i]; j++)
    //                 finalHeight[j] = max(finalHeight[j], height[i]);
    //         } else {
    //             for (int j = left[i]; j <= right[i]; j++)
    //                 finalHeight[j] = min(finalHeight[j], height[i]);
    //         }
    //     }
    //     return;
    // }

    tree.resize(4 * n, {0, INT_MAX});
    for(int i = 0; i < k; i++) {
        update(1, 0, n - 1, left[i], right[i], {op[i], height[i]});
    }

    output(1, 0, n - 1, finalHeight);
    
}

Compilation message

wall.cpp: In function 'void push(int, int, int)':
wall.cpp:18:5: error: 'laze' was not declared in this scope
   18 |     laze(x, {1, tree[x][0]});
      |     ^~~~
wall.cpp: In function 'void output(int, int, int, int*)':
wall.cpp:38:20: warning: value computed is not used [-Wunused-value]
   38 |         results[l] == tree[x][0];
wall.cpp: In function 'void update(int, int, int, int, int, Op)':
wall.cpp:51:15: warning: left operand of comma operator has no effect [-Wunused-value]
   51 |     if (r < a || b , l) return;
      |         ~~~~~~^~~~