답안 #731160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
731160 2023-04-27T05:52:09 Z Desh03 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;

struct segtree {
    vector<int> st, t, o;
    int sz;
    segtree(int n) {
        sz = n;
        while (__builtin_popcount(sz) ^ 1) sz++;
        st.resize(sz << 1), o.resize(sz << 1, -1);
    }
    void change(int v, int val, int op) {
        if (o[v] == -1 && v < sz) st[v] = val, o[v] = op;
        else if (op == 1) {
            if (st[v] <= val) {
                st[v] = val;
                o[v] = 1;
            }
        } else if (op == 2) {
            if (st[v] >= val) {
                st[v] = val;
                o[v] = 2;
            }
        }
    }
    void push(int v) {
        change(v << 1, st[v], o[v]);
        change(v << 1 | 1, st[v], o[v]);
        o[v] = -1;
    }
    void upd(int v, int l, int r, int ql, int qr, int op, int h) {
        if (l > qr || r < ql) return;
        if (l >= ql && r <= qr) {
            change(v, h, op);
            return;
        }
        if (o[v] != -1) push(v);
        int m = l + r >> 1;
        upd(v << 1, l, m, ql, qr, op, h);
        upd(v << 1 | 1, m + 1, r, ql, qr, op, h);
    }
    void pushdown(int v) {
        if (v >= sz) return;
        if (o[v] != -1) push(v);
        pushdown(v << 1);
        pushdown(v << 1 | 1);
    }
    void upd(int l, int r, int op, int h) {
        upd(1, 0, sz - 1, l, r, op, h);
    }
    int get(int i) {
        return st[i + sz];
    }
};

void buildwall(int n, int k, int op[], int left[], int right[], int hieght[], int finalhieght[]) {
    segtree st(n);
    for (int i = 0; i < k; i++)
        st.upd(left[i], right[i], op[i], hieght[i]);
    st.pushdown(1);
    for (int i = 0; i < n; i++) finalhieght[i] = st.get(i);
}

Compilation message

wall.cpp: In member function 'void segtree::upd(int, int, int, int, int, int, int)':
wall.cpp:39:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |         int m = l + r >> 1;
      |                 ~~^~~
/usr/bin/ld: /tmp/ccon5jqW.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