Submission #805368

# Submission time Handle Problem Language Result Execution time Memory
805368 2023-08-03T15:52:40 Z JoenPoenMan Wall (IOI14_wall) C++17
Compilation error
0 ms 0 KB
#include "wall.h"
#include "grader.cpp"

#include <bits/stdc++.h>
#define ALL(arr) begin(arr), end(arr)

using namespace std;
struct Tree {
    int v;
    int x, y;
    Tree *left = nullptr, *right = nullptr;
    Tree(int v, int x, int y) : v(v), x(x), y(y) {}
};

void update(int a, int b, bool rem, int h, Tree *t, int lazy = -1) {
    if (lazy != -1) t->v = lazy;
    if (b < t->x || a > t->y) return;
    if (a <= t->x && b >= t->y && !(t->left || t->right)) {
        if (!rem) {
            t->v = max(t->v, h);
        } else {
            t->v = min(t->v, h);
        }
        return;
    }
    if (!t->left) {
        t->left  = new Tree(0, t->x, (t->x + t->y)/2);
        update(a, b, rem, h, t->left, t->v);
    } else update(a, b, rem, h, t->left, -1);
    if (!t->right) {
        t->right = new Tree(0, (t->x + t->y)/2 + 1, t->y);
        update(a, b, rem, h, t->right, t->v);
    } else update(a, b, rem, h, t->right, -1);
}

void fillarr(int arr[], Tree *t) {
    if (t->left) {
        fillarr(arr, t->left);
        fillarr(arr, t->right);
    } else {
        for (int i = t->x; i <= t->y; i++) {
            arr[i] = t->v;
        }
    }
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
    Tree *t = new Tree(0, 0, n-1);
    for (int i = 0; i < k; i++) {
        update(left[i], right[i], (op[i] == 1 ? false : true), height[i], t);
    }
    fillarr(finalHeight, t);
}

Compilation message

/usr/bin/ld: /tmp/cc2INFq4.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1WjOs0.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status