Submission #725563

# Submission time Handle Problem Language Result Execution time Memory
725563 2023-04-17T16:32:04 Z allin27x Wall (IOI14_wall) C++17
8 / 100
134 ms 8200 KB
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

struct SGT{
	int op;
	vector<int> t;
	int n;
	SGT(int sz, int op1){
		n= sz;
		op = op1;
		t.resize(2*n, -1);
	}
	void apply(int p, int x){
		if (t[p]==-1) {t[p] = x; return;}
		t[p] = abs(max(op*t[p], op*x));
	}
	void update(int l, int r, int x){
		for (l+=n, r+=n+1; l<r; l>>=1, r>>=1){
			if (l&1) apply(l++, x);
			if (r&1) apply(--r, x);
		}
	}
	void push(){
		for (int i=1; i<n; i++){
			apply(i<<1, t[i]);
			apply(i<<1|1, t[i]);
		}
	}
};

void brute_force(int n, int k, int op[], int l[],int r[],int h[], int ans[]){
	for (int i=0; i<k; i++){
		for(int j=l[i]; j<=r[i]; j++){
			if (op[i] == 1) ans[j] = max(ans[j] , h[i]);
			if (op[i] == 2) ans[j] = min(ans[j] , h[i]);
		} 
	}
}
void buildWall(int n, int k, int op[], int l[],int r[],int h[], int ans[]){
	if (n<=10000)  {brute_force(n,k,op,l,r,h, ans); return;}
	SGT add(n, 1);
	SGT rem(n, -1);
	for (int i=0; i<k; i++){
		if (op[i]==1) add.update(l[i], r[i], h[i]);
		if (op[i]==2) rem.update(l[i], r[i], h[i]);
	}
	for (int i=0; i<n; i++) ans[i] = min(add.t[i+n], rem.t[i+n]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 21 ms 412 KB Output is correct
5 Correct 21 ms 468 KB Output is correct
6 Correct 25 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 134 ms 8076 KB Output is correct
3 Incorrect 84 ms 3788 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 22 ms 412 KB Output is correct
5 Correct 28 ms 408 KB Output is correct
6 Correct 21 ms 468 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 130 ms 8200 KB Output is correct
9 Incorrect 85 ms 3816 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 22 ms 408 KB Output is correct
5 Correct 24 ms 408 KB Output is correct
6 Correct 21 ms 408 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 132 ms 8124 KB Output is correct
9 Incorrect 84 ms 3888 KB Output isn't correct
10 Halted 0 ms 0 KB -