Submission #299137

#TimeUsernameProblemLanguageResultExecution timeMemory
299137vitkishloh228Wall (IOI14_wall)C++14
Compilation error
0 ms0 KiB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int, int>> t;//min,max
vector<int> mod;
void push(int v, int l, int r) {
	if (l == r) mod[v] = -1;
	else {
		if (mod[v] != -1) {
			mod[2 * v] = mod[v];
			mod[2 * v + 1] = mod[v];
			t[2 * v] = { mod[v],mod[v] };
			t[2 * v + 1] = t[2 * v];
			mod[v] = -1;
		}
	}
}
void upd1(int v, int tl, int tr, int l, int r, int x) {//if a[i]< h a[i]=h;
	push(v, tl, tr);
	if (tl > tr || l > r) return;
	if (tl == l && tr == r) {
		if (t[v].first > x) {
			return;
		}
		if (t[v].second <= x) {
			t[v] = { x,x };
			mod[v] = x;
			return;
		}
	}
	int tm = (tl + tr) / 2;
	upd1(2 * v, tl, tm, l, min(r, tm), x);
	upd1(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, x);
	t[v].first = min(t[2 * v].first, t[2 * v + 1].first);
	t[v].second = max(t[2 * v].second, t[2 * v + 1].second);
}
void upd0(int v, int tl, int tr, int l, int r, int x) {//if a[i]>h a[i]=h
	push(v, tl, tr);
	if (tl > tr || l > r) return;
	if (tl == l && tr == r) {
		if (t[v].second < x) {
			return;
		}
		if (t[v].first >= x) {
			t[v] = { x,x };
			mod[v] = x;
			return;
		}
	}
	int tm = (tl + tr) / 2;
	upd0(2 * v, tl, tm, l, min(r, tm), x);
	upd0(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, x);
	t[v].first = min(t[2 * v].first, t[2 * v + 1].first);
	t[v].second = max(t[2 * v].second, t[2 * v + 1].second);
}
int get(int v, int tl, int tr, int pos) {
	push(v, tl, tr);
	if (tl == tr) return t[v].first;
	else {
		int tm = (tl + tr) / 2;
		if (pos <= tm) return get(2 * v, tl, tm, pos);
		else return get(2 * v + 1, tm + 1, tr, pos);
	}
}
int main() {
	int n, q;
	cin >> n >> q;
	t.resize(4 * n);
	mod = vector<int>(4 * n, -1);
	while (q--) {
		int tt, l, r, h;
		cin >> tt >> l >> r >> h;
		//--l, --r;
		if (tt == 1) {
			upd1(1, 0, n - 1, l, r, h);
		}
		else {
			upd0(1, 0, n - 1, l, r, h);
		}
	}
	for (int i = 0; i < n; ++i) {
		cout << get(1, 0, n - 1, i) << ' ';
	}
}

Compilation message (stderr)

/tmp/ccO6Gvmj.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccMq2TkY.o:wall.cpp:(.text.startup+0x0): first defined here
/tmp/ccO6Gvmj.o: In function `main':
grader.cpp:(.text.startup+0x118): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status