#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)2e6+10;
int n, k, a[mxN];
array<int,2> seg[mxN*2],Init{0,mxN};
//maximize then minimize
void prop(int p, int l, int r){
if(l==r or seg[p]==Init) return;
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
for(int i : {0,1}){
seg[p+1][i] = min(max(seg[p+1][i],seg[p][0]),seg[p][1]);
seg[rp][i] = min(max(seg[rp][i],seg[p][0]),seg[p][1]);
}
seg[p] = Init;
}
void upd(int i, int j, int t, int v, int p=0, int l=0, int r=n-1){
if(i>r or j<l or i>j) return; prop(p,l,r);
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
if(i<=l and r<=j){ seg[p][t]=v; return; }
upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
}
void query(int p=0, int l=0, int r=n-1){
if(l==r){ a[l]=min(seg[p][0],seg[p][1]); return; } prop(p,l,r);
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
query(p+1,l,mid), query(rp,mid+1,r);
}
void buildWall(int N, int k, int o[], int l[], int r[], int h[], int ans[]){
n = N;
for(int i = 0; i <= 2*n; i++) seg[i]=Init;
for(int i = 0; i < k; i++) upd(l[i],r[i],o[i]-1,h[i]);
query(); for(int i = 0; i < n; i++) ans[i]=a[i];
}
Compilation message
wall.cpp: In function 'void upd(int, int, int, int, int, int, int)':
wall.cpp:18:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
18 | if(i>r or j<l or i>j) return; prop(p,l,r);
| ^~
wall.cpp:18:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
18 | if(i>r or j<l or i>j) return; prop(p,l,r);
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
128 ms |
8196 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |