#include <bits/stdc++.h>
#include <wall.h>
using namespace std;
//#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int mod = 1e9 + 7;
const int N = 1e5;
int SZN;
struct node{
int mn, mx, lazy;
};
node t[N*4];
void push(int v, int vl, int vr){
if(t[v].lazy == -1) return;
t[v].mn = t[v].mx = t[v].lazy;
if(vl != vr){
t[v<<1].lazy = t[v].lazy;
t[v<<1|1].lazy = t[v].lazy;
}
t[v].lazy = -1;
}
void update(int l, int r, int x, int v, int vl, int vr){
push(v, vl, vr);
if(l > vr or vl > r) return;
if(l <= vl and r >= vr){
t[v].lazy = x;
push(v, vl, vr);
return;
}
int mid = (vl + vr)>>1;
update(l, r, x, v<<1, vl, mid);
update(l, r, x, v<<1|1, mid+1, vr);
}
void mxeq(int l, int r, int x, int v, int vl, int vr){
push(v, vl, vr);
if(l > vr or vl > r) return;
if(l <= vl and r >= vr){
if(t[v].mn >= x) return;
if(vl == vr){
t[v] = {max(t[v].mn, x), max(t[v].mn, x), -1};
return;
}
if(t[v].mx <= x){
update(vl, vr, x, 1, 0LL, SZN-1);
return;
}
}
int mid = (vl + vr)>>1;
mxeq(l, r, x, v<<1, vl, mid);
mxeq(l, r, x, v<<1|1, mid+1, vr);
}
void mneq(int l, int r, int x, int v, int vl, int vr){
push(v, vl, vr);
if(l > vr or vl > r) return;
if(l <= vl and r >= vr){
if(t[v].mx <= x) return;
if(vl == vr){
t[v] = {x, x, -1};
return;
}
if(t[v].mn >= x){
update(vl, vr, x, 1, 0, SZN-1);
return;
}
}
int mid = (vl + vr)>>1;
mneq(l, r, x, v<<1, vl, mid);
mneq(l, r, x, v<<1|1, mid+1, vr);
}
node get(int pos, int v, int vl, int vr){
push(v, vl, vr);
if(vl == vr) return t[v];
int mid = (vl + vr)>>1;
if(mid >= pos) return get(pos, v<<1, vl, mid);
else return get(pos, v<<1|1, mid+1, vr);
}
void buildWall(int n, int k, int op[], int left[], int right[],
int height[], int finalHeight[]){
for(int i = 0;i < 4*N; i++){
t[i] = {INT_MAX, INT_MIN, -1};
}
for(int i = 0;i < k; i++){
int type = op[i], l = left[i], r = right[i], x = height[i];
if(type == 1){
mxeq(l, r, x, 1, 0, n-1);
}else{
mneq(l, r, x, 1, 0, n-1);
}
}
for(int i = 0;i < n; i++){
finalHeight[i] = get(i, 1, 0, n-1).mn;
}
}
/*
10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 5 5
2 6 7 0
*/
/*
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin >> n;
int q; cin >> q;
int op[q], Left[q], Right[q], height[q];
for(int i = 0;i < q; i++){
cin >> op[i] >> Left[i] >> Right[i] >> height[i];
}
int F[n];
buildWall(n, q, op, Left, Right, height, F);
for(int i = 0;i < n; i++) cout << F[i] << ' ';
return 0;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |