이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define N 2000005
struct A{
int mi,ma,exact;
};
A t[4*N];
int ll,rr,ma,mi;
void op(A &t,A add){
auto [mi,ma,exact]=add;
if(exact!=-1)t=add;
else if(t.mi!=-1){
if(t.exact==-1){
t.ma=min(t.ma,ma);
t.mi=max(t.mi,mi);
if(t.mi>t.ma){
if(t.mi==mi)t.exact=mi;
else t.exact=ma;
}
}
else{
if(t.exact<mi)t.exact=mi;
else if(t.exact>ma)t.exact=ma;
}
}
else t=add;
}
void push(int x){
if(t[x].mi!=-1){
int xl=x*2,xr=xl+1,mi=t[x].mi,ma=t[x].ma;
op(t[xl],t[x]);
op(t[xr],t[x]);
t[x].mi=-1;
}
}
void cre(int x,int l,int r){
if(l==r)return ;
t[x]={-1,-1,-1};
int mid=(l+r)/2;
cre(x*2,l,mid);
cre(x*2+1,mid+1,r);
}
void update(int x,int l,int r){
if(r<ll||rr<l)return ;
if(ll<=l&&r<=rr){
op(t[x],{mi,ma,-1});
return ;
}
push(x);
int mid=(l+r)/2;
update(x*2,l,mid);
update(x*2+1,mid+1,r);
}
void sol(int x,int l,int r,int *ans){
if(l==r){ans[l-1]=t[x].exact;return ;}
push(x);
int mid=(l+r)/2;
sol(x*2,l,mid,ans);
sol(x*2+1,mid+1,r,ans);
}
void buildWall(int n, int k, int *op, int *left, int *right, int *height, int *finalHeight){
int i,h;
cre(1,1,n);
for(i=0;i<k;i++){
ll=left[i]+1;
rr=right[i]+1;
h=height[i];
if(op[i]==1)mi=h,ma=100000;
else mi=0,ma=h;
update(1,1,n);
}
sol(1,1,n,finalHeight);
}
컴파일 시 표준 에러 (stderr) 메시지
wall.cpp: In function 'void push(int)':
wall.cpp:34:28: warning: unused variable 'mi' [-Wunused-variable]
34 | int xl=x*2,xr=xl+1,mi=t[x].mi,ma=t[x].ma;
| ^~
wall.cpp:34:39: warning: unused variable 'ma' [-Wunused-variable]
34 | int xl=x*2,xr=xl+1,mi=t[x].mi,ma=t[x].ma;
| ^~
# | 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... |