# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699513 | nguyentunglam | Wall (IOI14_wall) | C++17 | 0 ms | 0 KiB |
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>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 2e6 + 10;
int a[N], L[N << 2], R[N << 2];
int range(int l, int r, int val) {
return min(r, max(l, val));
}
void push(int s, int l, int r) {
if (l == r) return;
L[s << 1] = range(L[s], R[s], L[s << 1]);
R[s << 1] = range(L[s], R[s], R[s << 1]);
L[s << 1 | 1] = range(L[s], R[s], L[s << 1 | 1]);
R[s << 1 | 1] = range(L[s], R[s], R[s << 1 | 1]);
L[s] = 0; R[s] = 1e5;
}
void up(int s, int l, int r, int from, int to, int val, int type) {
push(s, l, r);
if (l > to || r < from) return;
if (from <= l && r <= to) {
if (type == 1) {
L[s] = max(L[s], val);
R[s] = max(R[s], val);
}
else {
L[s] = min(L[s], val);
R[s] = min(R[s], val);
}
push(s, l, r);
return;
}
int mid = l + r >> 1;
up(s << 1, l, mid, from, to, val, type);
up(s << 1 | 1, mid + 1, r, from, to, val ,type);
}
void get(int s, int l, int r) {
push(s, l, r);
if (l == r) {
a[l] = L[s];
return;
}
int mid = l + r >> 1;
get(s << 1, l, mid);
get(s << 1 | 1, mid + 1, r);
}
int main() {
#define task ""
cin.tie(0) -> sync_with_stdio(0);
if (fopen ("task.inp", "r")) {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
}
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int n, k; cin >> n >> k;
for(int i = 1; i <= 4 * n; i++) R[i] = 1e5;
while (k--) {
int op, l, r, h; cin >> op >> l >> r >> h;
up(1, 0, n - 1, l, r, h, op);
}
get(1, 0, n - 1);
for(int i = 0; i < n; i++) cout << a[i] << " ";
}