#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1000;
vector<int> a(N);
vector<pair<long long, long long>> t(4 * N);
vector<int>lazy(4 * N);
void push(int v, int vl, int vr){
if (vr == vl) return;
t[2 * v].first = min(max(t[2 * v].first, t[v].first), t[v].second);
t[2 * v ].second = max(min(t[2 * v].second, t[v].second), t[v].first);
t[2 * v + 1].first = min(max(t[2 * v + 1].first, t[v].first), t[v].second);
t[2 * v + 1].second = max(min(t[2 * v + 1].second, t[v].second), t[v].first);
t[v] = {0, 1e9};
}
void update(int v, int vl, int vr, int l, int r, long long x, int tt){
if (vl > r || vr < l) return;
push(v, vl ,vr);
if (vl >= l && vr <= r){
if (tt == 1){
t[v] = {max(t[v].first, x), max(t[v].second, x)};
}else{
t[v] = {min(t[v].first, x), min(t[v].second, x)};
}
push(v, vl ,vr);
return;
}
int vm = (vl + vr) / 2;
update(2 * v, vl, vm, l, r, x, tt);
update(2 * v + 1, vm + 1, vr, l, r, x, tt);
}
int get(int v, int vl, int vr, int x){
if (vl > x || vr < x) return 0;
push(v, vl ,vr);
if (vr <= x && x <= vl){
return t[v].first;
}
int vm = (vl + vr) / 2;
return max(get(2 * v, vl, vm, x), get(2 * v + 1, vm + 1, vr, x));
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i = 0; i < n; i++){
a[i] = 0;
}
//build(1, 0, n - 1);
for (int i = 0; i < k; i++){
if (op[i] == 1){
update(1, 0, n - 1, left[i], right[i], height[i], 1);
}else update(1, 0, n - 1, left[i], right[i], height[i], 2);
}
for (int i = 0; i < n; i++){
finalHeight[i] = get(1, 0, n - 1, i);
}
return;
}
int main(){
int n, k; cin >> n >> k;
int left[k], right[k], height[k], op[k], finalHeight[k];
for (int i = 0; i < k; i++){
cin >> op[i] >> left[i] >> right[i] >> height[i];
}
buildWall(n, k, op, left, right, height, finalHeight);
for (int i = 0; i < n; i++) {
cout << finalHeight[i] << endl;
}
cout << endl;
}
Compilation message
/usr/bin/ld: /tmp/cccpCOAe.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccdylDcf.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status