이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
#define fore(a, b, c) for(int a=b; a<c; ++a)
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define ii pair<int,int>
#define vi vector<int>
struct segtree {
    vi t;
    int n;
    vector<set<array<int,3>>> lazy;
    segtree(int n) : n(n) {
        t.assign(4*n, 0);
        lazy.assign(4*n, {});
    }
    void updateMx(int i, int tl, int tr, int l, int r, int val, int id){
        if(l <= tl && tr <= r){
            lazy[i].insert({id, 1, val});
            return;
        }
        if(r < tl or tr < l){
            return;
        }
        int tm = (tl + tr) / 2;
        updateMx(2*i+1, tl, tm, l, r, val, id);
        updateMx(2*i+2, tm+1, tr, l, r, val, id);
    }
    void updateMx(int l, int r, int val, int id){
        updateMx(0, 0, n-1, l, r, val, id);
    }
    void updateMn(int i, int tl, int tr, int l, int r, int val, int id){
        if(l <= tl && tr <= r){
            lazy[i].insert({id, 2, val});
            return;
        }
        if(r < tl or tr < l){
            return;
        }
        int tm = (tl + tr) / 2;
        updateMn(2*i+1, tl, tm, l, r, val, id);
        updateMn(2*i+2, tm+1, tr, l, r, val, id);
    }
    void updateMn(int l, int r, int val, int id){
        updateMn(0, 0, n-1, l, r, val, id);
    }
    void push(int i, int tl, int tr){
        if(sz(lazy[i]) == 0) return;
        lazy[2*i+1].insert(all(lazy[i]));
        lazy[2*i+2].insert(all(lazy[i]));
        lazy[i].clear();
    }
    int query(int i, int tl, int tr, int idx){
        if(tl == tr){
            for(auto [id, type, val] : lazy[i]){
                if(type == 1){
                    t[i] = max(t[i], val);
                } else {
                    t[i] = min(t[i], val);
                }
            }
            return t[i];
        }
        push(i, tl, tr);
        int tm = (tl + tr) / 2;
        if(idx <= tm){
            return query(2*i+1, tl, tm, idx);
        } else {
            return query(2*i+2, tm+1, tr, idx);
        }
    }
    int query(int idx){
        return query(0, 0, n-1, idx);
    }
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    segtree T(n);
    fore(i, 0, k){
        if(op[i] == 1){
            T.updateMx(left[i], right[i], height[i], i);
        } else {
            T.updateMn(left[i], right[i], height[i], i);
        }
    }
    fore(i, 0, n){
        finalHeight[i] = T.query(i);
    }
    return;
}
컴파일 시 표준 에러 (stderr) 메시지
wall.cpp: In member function 'int segtree::query(int, int, int, int)':
wall.cpp:65:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   65 |             for(auto [id, type, val] : lazy[i]){
      |                      ^| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |