This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "wall.h"
#include <bits/stdc++.h>
#define mn first
#define mx second
using namespace std;
int ans[2000005];
pair<int,int> v[8000000];
struct stree{
void upd(int x,int mn,int mx){
v[x].mn=min(max(mn,v[x].mn),mx);
v[x].mx=min(max(mn,v[x].mx),mx);
}
void push(int x,int l,int r){
if(r!=l){
upd(x*2+1,v[x].mn,v[x].mx);
upd(x*2,v[x].mn,v[x].mx);
}
v[x]={0,2e9};
}
void update(int x,int lx,int rx,int l,int r,int mn,int mx){
if(lx>=l&&r>=rx){
upd(x,mn,mx);
return;
}
if(rx<l||lx>r)
return;
push(x,lx,rx);
int m=(lx+rx)/2;
update(x*2+1,lx,m,l,r,mn,mx);
update(x*2,m+1,rx,l,r,mn,mx);
}
void build(int x,int l,int r){
if(l==r){
ans[l]=v[x].mn;
return;
}
push(x,l,r);
int m=(l+r)/2;
build(x*2+1,l,m);
build(x*2,m+1,r);
}
};
void buildWall(int n, int k, int w[], int l[], int r[], int h[], int a[]){
stree t;
for(int i=0;i<k;i++){
int mn=w[i]==1 ? h[i]:0,mx=w[i]==2 ? h[i]:INT_MAX;
t.update(0,0,n-1,l[i],r[i],mn,mx);
}
t.build(0,0,n-1);
for(int i=0;i<n;i++)ans[i]=a[i];
return ;
}
/*
10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 2 5
2 6 7 0
*/
| # | 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... |