This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
typedef int ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e6 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define lc (id << 1)
#define rc (lc | 1)
pll seg[maxn << 2];
ll ans[maxn];
pll Do(pll f, pll s){
if(f.S < s.F) return Mp(s.F, s.F);
if(f.F > s.S) return Mp(s.S, s.S);
return Mp(max(f.F, s.F), min(f.S, s.S));
}
void shift(ll id){
seg[lc] = Do(seg[lc], seg[id]);
seg[rc] = Do(seg[rc], seg[id]);
seg[id] = Mp(0, inf);
return;
}
void upd(ll id, ll s, ll e, ll l, ll r, pll x){
if(r <= s || e <= l) return;
if(l <= s && e <= r){
seg[id] = Do(seg[id], x);
return;
}
ll mid = (s + e) >> 1;
shift(id);
upd(lc, s, mid, l, r, x);
upd(rc, mid, e, l, r, x);
return;
}
void fix(ll id, ll s, ll e){
if(e - s == 1){
ans[s] = seg[id].F;
return;
}
ll mid = (s + e) >> 1;
shift(id);
fix(lc, s, mid);
fix(rc, mid, e);
return;
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
fill(seg, seg + (n << 2), Mp(0, inf));
for(ll i = 0; i < k; i++){
if(op[i] == 1){
upd(1, 0, n, left[i], right[i] + 1, Mp(height[i], inf));
}
else{
upd(1, 0, n, left[i], right[i] + 1, Mp(0, height[i]));
}
}
fix(1, 0, n);
for(ll i = 0; i < n; i++){
finalHeight[i] = ans[i];
}
return;
}
/*int main(){
fast_io;
return 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... |