이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wall.h"
#include <bits/stdc++.h>
#define ADD 1
using namespace std;
int const maxn = 1 << 21;
int N;
pair<int, int> t[maxn << 2];
void push(int v){
    t[v << 1].first = min(max(t[v << 1].first, t[v].first), t[v].second);
    t[v << 1 | 1].first = min(max(t[v << 1 | 1].first, t[v].first), t[v].second);
    t[v << 1].second = min(max(t[v << 1].second, t[v].first), t[v].second);
	t[v << 1 | 1].second = min(max(t[v << 1 | 1].second, t[v].first), t[v].second);
}
void update(int v, int tl, int tr, int l, int r, int h, int upd){
	if(l <= tl && tr <= r) {
	    if (upd == ADD){
	        t[v].first = max(t[v].first, h);
	        t[v].second = max(t[v].second, h);
		} else{
	        t[v].first = min(t[v].first, h);
	        t[v].second = min(t[v].second, h);
		}
		return;
	}   
	if(l > tr || r < tl)
	    return;
	push(v);
	int tm = tl + tr >> 1;
	update(v << 1, tl, tm, l, r, h, upd);
	update(v << 1 | 1, tm + 1, tr, l, r, h, upd);
    t[v].first = min(t[v << 1].first, t[v << 1 | 1].first);
    t[v].second = min(t[v << 1].second, t[v << 1 | 1].second);
}
int res[maxn];
void rebuild(int v, int tl, int tr){
    if(tl >= N) return;
	if (tl == tr){
		res[tl] = t[v].first;
		return;
	}
	push(v);
	int tm = tl + tr >> 1;
	rebuild(v << 1, tl, tm);
	rebuild(v << 1 | 1, tm + 1, tr);
}
 
void buildWall(int n, int k, int op[], int _left[], int _right[], int height[], int finalHeight[]){
    N = n;
	for (int i = 0; i < k; i++)
	    update(1, 0, maxn - 1, _left[i] + 1, _right[i] + 1, height[i], op[i]);
	rebuild(1, 0, maxn - 1);
	for(int i = 0; i < n; i ++)
	    finalHeight[i] = res[i];
}
컴파일 시 표준 에러 (stderr) 메시지
wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:28:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |  int tm = tl + tr >> 1;
      |           ~~~^~~~
wall.cpp: In function 'void rebuild(int, int, int)':
wall.cpp:42:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |  int tm = tl + tr >> 1;
      |           ~~~^~~~| # | 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... |