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 <bits/stdc++.h>
#include "wall.h"
#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
#define random (rand() ^ (rand() << 15))
using namespace std;
const int N = (int)2e6 + 7;
const int inf = (int)1e9 + 7;
int n, c;
struct T {
int mn, mx;
T() {
mn = 1e5;
mx = 0;
}
};
T tree[N * 4];
int* a;
void push(int v, int op, int val) {
if (op == 1) {
tree[v].mn = max(tree[v].mn, val);
tree[v].mx = max(tree[v].mx, val);
} else if (op == 2) {
tree[v].mn = min(tree[v].mn, val);
tree[v].mx = min(tree[v].mx, val);
}
}
void upd(int v, int tl, int tr, int l, int r, int op, int val) {
if (tl > r || tr < l) return ;
if (l <= tl && tr <= r) {
push(v, op, val);
a[l] = tree[v].mx;
return ;
}
int mid = (tl + tr) >> 1;
push(v + v, 1, tree[v].mx);
push(v + v + 1, 1, tree[v].mx);
push(v + v, 2, tree[v].mn);
push(v + v + 1, 2, tree[v].mn);
tree[v] = T();
upd(v + v, tl, mid, l, r, op, val);
upd(v + v + 1, mid + 1, tr, l, r, op, val);
}
void buildWall(int nn, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
n = nn;
a = finalHeight;
for (int i = 0; i < k; i++) {
upd(1, 0, n - 1, left[i], right[i], op[i], height[i]);
}
for (int i = 0; i < n; i++) {
upd(1, 0, n - 1, i, i, 1, 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... |