답안 #1014359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014359 2024-07-04T18:43:04 Z Ariadna 벽 (IOI14_wall) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

const int INF = 2e9+1;

struct Segtree {
    int n;
    vector<int> st_min, st_max;

    Segtree(int N) {
        n = N;
        st_min = vector<int>(4*n, INF);
        st_max = vector<int>(4*n, 0);
    }

    void push(int p, int l, int r) {
        if (l == r) return;
        st_min[2*p] = max(st_max[p], min(st_min[2*p], st_min[p]));
        st_max[2*p] = min(st_min[p], max(st_max[2*p], st_max[p]));
        st_min[2*p+1] = max(st_max[p], min(st_min[2*p+1], st_min[p]));
        st_max[2*p+1] = min(st_min[p], max(st_max[2*p+1], st_max[p]));
    }

    void minimize(int p, int l, int r, int i, int j, int k) {
        if (i > j) return;
        push(p, l, r);
        if (i == l && j == r) {
            st_min[p] = min(st_min[p], k);
            st_max[p] = min(st_min[p], st_max[p]);
        } else {
            int m = (l+r)/2;
            minimize(2*p, l, m, i, min(m, j), k);
            minimize(2*p+1, m+1, r, max(i, m+1), j, k);
        }
    }

    void maximize(int p, int l, int r, int i, int j, int k) {
        if (i > j) return;
        push(p, l, r);
        if (i == l && j == r) {
            st_max[p] = max(st_max[p], k);
            st_min[p] = max(st_min[p], st_max[p]);
        } else {
            int m = (l+r)/2;
            maximize(2*p, l, m, i, min(m, j), k);
            maximize(2*p+1, m+1, r, max(i, m+1), j, k);
        }
    }

    void values(int p, int l, int r, vector<int>& h) {
        if (l == r) 
            h[l] = min(st_min[p], st_max[p]);
        else {
            push(p, l, r);
            int m = (l+r)/2;
            values(2*p, l, m, h);
            values(2*p+1, m+1, r, h);
        }
    }

    vector<int> final_height() {
        vector<int> return_values(n);
        values(1, 0, n-1, return_values);
        return return_values;
    }
};

void buildWall(int n, int k, vector<int> op, vector<int> left, vector<int> right, vector<int> height, vector<int> finalHeight) {
    Segtree St(n);
    for (int i = 0; i < k; ++i) {
        if (op[i] == 1)
            St.maximize(1, 0, n-1, left[i], right[i], height[i]);
        else 
            St.minimize(1, 0, n-1, left[i], right[i], height[i]);
    }

    finalHeight = St.final_height();
}

/*int main() {
    int n, k;
    cin >> n >> k;
    vector<int> op(k), l(k), r(k), h(k), final;
    for (int i = 0; i < k; ++i) cin >> op[i] >> l[i] >> r[i] >> h[i];
    buildWall(n, k, op, l, r, h, final);
}*/

Compilation message

/usr/bin/ld: /tmp/ccpa8EGH.o: in function `main':
grader.cpp:(.text.startup+0x133): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status