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>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) (v).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e6+7;
vector <pii> lz(N*3);
vector <int> res(N);
void upd(int v, int mn, int mx){
lz[v].first = min(max(lz[v].first, mn), mx);
lz[v].second = min(max(lz[v].second, mn), mx);
}
void push(int v, int l, int r){
if(l != r){
upd(v<<1, lz[v].first, lz[v].second);
upd((v<<1)+1, lz[v].first, lz[v].second);
}
lz[v] = {0, 2e9};
}
void update(int v, int l, int r, int ql, int qr, int op, int h){
if(r < ql || l > qr) return;
if(ql <= l && r <= qr){
upd(v, (op==1?h:0), (op==2?h:2e9));
return;
}
push(v, l, r);
int mid = (l+r)>>1;
update(v<<1, l, mid, ql, qr, op, h);
update((v<<1)+1, mid+1, r, ql, qr, op, h);
}
void build(int v, int l, int r){
if(l == r){
res[l] = lz[v].first;
return;
}
push(v, l, r);
int mid = (l+r) >> 1;
build(v<<1, l, mid);
build((v<<1)+1, mid+1, r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for(int i = 0; i < k; i++){
update(1, 0, n-1, left[i], right[i], op[i], height[i]);
}
build(1, 0, n-1);
for(int i = 0; i < n; i++){
finalHeight[i] = res[i];
}
return;
}
/*
int main(){
int n, k, i, j, status = 0;
status = scanf("%d%d", &n, &k);
assert(status == 2);
int* op = (int*)calloc(sizeof(int), k);
int* left = (int*)calloc(sizeof(int), k);
int* right = (int*)calloc(sizeof(int), k);
int* height = (int*)calloc(sizeof(int), k);
int* finalHeight = (int*)calloc(sizeof(int), n);
for (i = 0; i < k; i++){
status = scanf("%d%d%d%d", &op[i], &left[i], &right[i], &height[i]);
assert(status == 4);
}
buildWall(n, k, op, left, right, height, finalHeight);
for (j = 0; j < n; j++)
printf("%d\n", finalHeight[j]);
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... |