# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930155 | FanOfWilliamLin | 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 fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 2e6 + 5;
struct node {
int up = 0, down = 1e5 + 5;
node() {}
}
d[4 * N];
void apply(int ind, int up, int down) {
if (ind >= 0 && ind < 4 * N) {
d[ind].down = min(d[ind].down, down);
d[ind].down = max(d[ind].down, up);
d[ind].up = max(d[ind].up, up);
d[ind].up = min(d[ind].up, down);
}
}
void range_modify(int mode, int ml, int mr, int val, int ind = 1, int l = 0, int r = N - 1) {
if (ml > r || mr < l) return;
if (ml <= l && mr >= r) {
if (mode) {
d[ind].down = min(d[ind].down, val);
d[ind].up = min(d[ind].up, val);
} else {
d[ind].down = max(d[ind].down, val);
d[ind].up = max(d[ind].up, val);
}
return;
}
int mid = (l + r) / 2;
apply(ind << 1, d[ind].up, d[ind].down);
apply(ind << 1 | 1, d[ind].up, d[ind].down);
d[ind].up = 0, d[ind].down = 1e5 + 5;
range_modify(mode, ml, mr, val, ind << 1, l, mid);
range_modify(mode, ml, mr, val, ind << 1 | 1, mid + 1, r);
}
int n, k;
void query(int ind, int l, int r) {
if (l == r) {
if (l != n) cout << min(d[ind].up, d[ind].down) << "\n";
return;
}
apply(ind << 1, d[ind].up, d[ind].down);
apply(ind << 1 | 1, d[ind].up, d[ind].down);
d[ind].up = 0, d[ind].down = 1e5 + 5;
int mid = l + r >> 1;
query(ind << 1, l, mid);
query(ind << 1 | 1, mid + 1, r);
}
signed main() {
fastio
cin >> n >> k;
while (k--) {
int mode, l, r, val;
cin >> mode >> l >> r >> val;
range_modify(mode - 1, l, r, val, 1, 0, n);
}
query(1, 0, n);
}