This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// looking to shine brighter in this world...
#define TASK "wall"
#include "wall.h"
#ifdef LOCAL
#include "local.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#define DB(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define For(i, l, r) for (int i = (l); i <= (r); ++i)
#define Ford(i, r, l) for (int i = (r); i >= (l); --i)
#define Rep(i, n) For (i, 0, (n) - 1)
#define Repd(i, n) Ford (i, (n) - 1, 0)
#define Fe(...) for (auto __VA_ARGS__)
template <class C> inline int isz(const C& c) { return static_cast<int>(c.size()); }
template <class T> inline bool chmin(T& a, const T& b) { return (a > b) ? a = b, true : false; }
template <class T> inline bool chmax(T& a, const T& b) { return (a < b) ? a = b, true : false; }
const bool __initialization = []() {
cin.tie(nullptr)->sync_with_stdio(false);
if (fopen(TASK".inp", "r")) {
(void)(!freopen(TASK".inp", "r", stdin));
(void)(!freopen(TASK".out", "w", stdout)); }
cout << setprecision(12) << fixed;
return true;
}();
constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;
// =============================================================================
constexpr int maxn = 2e6 + 5;
struct Node {
int min, max;
};
int n, k;
Node tree[maxn << 2];
int ans[maxn];
void updateMax(int u, int v, int val, int i = 1, int l = 0, int r = n - 1) {
if (v < l || r < u || tree[i].min >= val) return;
if (l == r) {
ans[l] = val;
tree[i] = { val, val };
return;
}
int m = (l + r) / 2;
updateMax(u, v, val, i << 1, l, m);
updateMax(u, v, val, i << 1 | 1, m + 1, r);
tree[i].min = min(tree[i << 1].min, tree[i << 1 | 1].min);
tree[i].max = max(tree[i << 1].max, tree[i << 1 | 1].max);
}
void updateMin(int u, int v, int val, int i = 1, int l = 0, int r = n - 1) {
if (v < l || r < u || tree[i].max <= val) return;
if (l == r) {
ans[l] = val;
tree[i] = { val, val };
return;
}
int m = (l + r) / 2;
updateMin(u, v, val, i << 1, l, m);
updateMin(u, v, val, i << 1 | 1, m + 1, r);
tree[i].min = min(tree[i << 1].min, tree[i << 1 | 1].min);
tree[i].max = max(tree[i << 1].max, tree[i << 1 | 1].max);
}
void buildWall(int N, int K, int op[], int l[], int r[], int h[], int ret[]) {
{ n = N; k = K; }
Rep (i, k) {
if (op[i] == 2) {
updateMin(l[i], r[i], h[i]);
}
else {
updateMax(l[i], r[i], h[i]);
}
}
Rep (i, n) {
ret[i] = ans[i];
}
}
# | 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... |