이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wall.h"
#include<bits/stdc++.h>
using namespace std;
int N;
vector<pair<int,int>> lazy;
void merge(int node, pair<int,int> p){
if (p.second >= lazy[node].first && lazy[node].second >= p.first){
lazy[node].first = max(lazy[node].first, p.first);
lazy[node].second = min(lazy[node].second, p.second);
return;
}
if (p.first > lazy[node].second) lazy[node] = {p.first, p.first};
else lazy[node] = {p.second, p.second};
return;
}
void prop(int node){
merge(node*2, lazy[node]);
merge(node*2+1, lazy[node]);
lazy[node] = {0, 100000};
return;
}
void update(int l, int r, pair<int,int> p, int node=1, int tl=0, int tr=N-1){
if (l <= tl && tr <= r){
merge(node, p);
return;
}
prop(node);
int tm = (tl+tr)/2;
if (l <= tm) update(l, r, p, node*2, tl, tm);
if (tm+1 <= r) update(l, r, p, node*2+1, tm+1, tr);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
N = n;
lazy.resize(4*n, {0, 100000});
for (int i=0; i<k; i++){
if (op[i] == 1) update(left[i], right[i], {height[i], 100000});
else update(left[i], right[i], {0, height[i]});
}
for (int i=0; i<n; i++){
finalHeight[i] = 0;
int cur = 1, tl = 0, tr = n-1;
while (tl != tr){
int tm = (tl+tr)/2;
if (i <= tm){
cur = cur*2;
tr = tm;
}
else {
cur = cur*2+1;
tl = tm+1;
}
}
while (cur){
if (finalHeight[i] < lazy[cur].first) finalHeight[i] = lazy[cur].first;
if (finalHeight[i] > lazy[cur].second) finalHeight[i] = lazy[cur].second;
cur >>= 1;
}
}
return;
}
# | 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... |