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 ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 2e6 + 1;
vector <int> l(4 * nmax), r(4 * nmax, 1e9 + 1);
void pp(int x, int y){
if(l[x] > r[y]){
l[y] = r[y] = l[x];
return;
}
if(r[x] < l[y]){
l[y] = r[y] = r[x];
return;
}
l[y] = max(l[x], l[y]);
r[y] = min(r[y], r[x]);
}
void push(int v){
pp(v, 2 * v);
pp(v, 2 * v+ 1);
l[v] = 0, r[v] = 1e9 + 1;
}
void update(int v, int L, int R, int st, int fin, int val, int o){
if(L > fin || R < st) return;
if(L >= st && R <= fin){
if(o == 1){
if(val > r[v]) l[v] = r[v] = val;
else l[v] = val;
}
if(o == 2){
if(val < l[v]) l[v] = r[v] = val;
else r[v] = val;
}
return;
}
int m = (L + R) / 2;
push(v);
update(2 * v, L, m, st, fin, val, o);
update(2 * v + 1, m + 1, R, st, fin, val, o);
}
int get(int v, int L, int R, int pos){
if(L == R){
return l[v];
}
int m = (L + R) / 2;
push(v);
if(pos <= m) return get(2 * v, L, m, pos);
return get(2 * v+ 1, m + 1, R, pos);
}
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], height[i], op[i]);
}
for(int i = 0; i < n; i++){
finalHeight[i] = get(1, 0, n - 1, 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... |