이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wall.h"
#include<bits/stdc++.h>
using namespace std;
int lim;
pair<int,int> st[8000001];
pair<int,int> reiniciar={0,1000000000};
void heredar(int pos){
for(int i=pos*2;i<=pos*2+1;i++){
st[i].second=min(st[i].second,st[pos].second);
if(st[pos].second<=st[i].first) st[i].first=max(st[pos].second,st[pos].first);
else st[i].first=max(st[i].first,st[pos].first);
}
st[pos]=reiniciar;
}
void iniciar(int i=0,int j=lim-1,int pos=1){
if(i==j) st[pos]=reiniciar;
else{
iniciar(i,(i+j)/2);
iniciar((i+j)/2+1,j);
}
}
void st_actualizar(int tp,int alt,int izq,int der,int i=0,int j=lim-1,int pos=1){
if(izq==i&&der==j){
if(tp==2){
st[pos].second=min(st[pos].second,alt);
if(st[pos].first>0) st[pos].first=min(st[pos].first,alt);
}
else st[pos].first=max(st[pos].first,alt);
}
else{
if(st[pos].first>0||st[pos].second<1000000000) heredar(pos);
if(izq<=(i+j)/2) st_actualizar(tp,alt,izq,min(der,(i+j)/2),i,(i+j)/2,pos*2);
if(der>(i+j)/2) st_actualizar(tp,alt,max(izq,(i+j)/2+1),der,(i+j)/2+1,j,pos*2+1);
}
return;
}
int resultado[2000000];
void revision(int i=0,int j=lim-1,int pos=1){
if(i==j){
resultado[i]=st[pos].first;
}
else{
if(st[pos].first>0||st[pos].second<1000000000) heredar(pos);
revision(i,(i+j)/2,pos*2);
revision((i+j)/2+1,j,pos*2+1);
}
return;
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
lim=n; iniciar();
for(int i=0;i<k;i++){
st_actualizar(op[i],height[i],left[i],right[i]);
}
revision();
for(int i=0;i<n;i++){
finalHeight[i]=resultado[i];
}
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... |