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;
const int SIZE = 1<<21;
int *fin;
struct ST{
int mn[2*SIZE], mx[2*SIZE];
void update(int nn, int ns, int ne, int s, int e, int x, int q){
if(ns>e || ne<s) return;
if(s<=ns && ne<=e){
if(q==1)
mn[nn] = mx[nn] = max(mn[nn], x);
else if(q==2)
mx[nn] = mn[nn] = min(mn[nn], x);
if(ns==ne) fin[ns] = mx[nn];
return;
}
int m =(ns+ne)/2;
int l = nn*2, r = l+1;
mn[l] = min(mn[l], mn[nn]); mn[r] = min(mn[r], mn[nn]);
mx[l] = min(mx[l], mn[nn]); mx[r] = min(mx[r], mn[nn]);
mn[l] = max(mn[l], mx[nn]); mn[r] = max(mn[r], mx[nn]);
mx[l] = max(mx[l], mx[nn]); mx[r] = max(mx[r], mx[nn]);
mx[nn] = 0; mn[nn] = 1e9;
update(l, ns, m, s, e, x, q);
update(r, m+1, ne, s, e, x, q);
}
}seg;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
fin = finalHeight;
for(int i=0; i<k; ++i){
seg.update(1, 0, n-1, left[i], right[i], height[i], op[i]);
}
for(int i=0; i<n; ++i)
seg.update(1, 0, n-1, i, i, 0, 0);
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... |