#include <wall.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <climits>
using namespace std;
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair <int, int>
#define ull unsigned long long
// #define int long long
// #define int unsigned long long
const ll inf = 1e9 + 7;
const ll weirdMod = 998244353;
int n, k;
struct node {
int mn = INT_MAX, mx = 0;
}; vector<node> lazy;
void modify(node &a, node b) {
if (b.mn < a.mx) {
a.mx = b.mn;
a.mn = b.mn;
} else if (b.mx > a.mn) {
a.mx = b.mx;
a.mn = b.mx;
} else {
a.mx = max(a.mx, b.mx);
a.mn = min(a.mn, b.mn);
}
}
void propagate(int v) {
modify(lazy[2 * v], lazy[v]);
modify(lazy[2 * v + 1], lazy[v]);
lazy[v].mn = INT_MAX; lazy[v].mx = 0;
}
void update(int v, int tl, int tr, int l, int r, node u) {
if (r < tl || tr < l)
return;
if (l <= tl && tr <= r) {
modify(lazy[v], u);
return;
} if (tl != tr)
propagate(v);
int tm = (tl + tr) / 2;
update(2 * v, tl, tm, l, min(r, tm), u);
update(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, u);
}
void adding(int l, int r, int h) {
node v = *new node();
v.mx = h; v.mn = INT_MAX;
update(1, 1, n, l, r, v);
}
void removing(int l, int r, int h) {
node v = *new node();
v.mn = h; v.mx = 0;
update(1, 1, n, l, r, v);
}
int getval(int v, int tl, int tr, int pos) {
if (tl == tr)
return lazy[v].mx;
propagate(v);
int tm = (tl + tr) / 2;
if (pos <= tm) return getval(2 * v, tl, tm, pos);
else return getval(2 * v + 1, tm + 1, tr, pos);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
lazy.resize(4 * n);
for (int i = 0; i < k; i++) {
if (op[i] == 1) adding(left[i] + 1, right[i] + 1, height[i]);
else removing(left[i] + 1, right[i] + 1, height[i]);
} for (int i = 0; i < n; i++)
finalHeight[i] = getval(1, 1, n, i + 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |