Submission #282483

# Submission time Handle Problem Language Result Execution time Memory
282483 2020-08-24T13:03:06 Z amoo_safar Wall (IOI14_wall) C++17
100 / 100
846 ms 71676 KB
#include "wall.h"

#include <bits/stdc++.h>

using namespace std;

const int N = 2097152;
const int Inf = 100000;

int sL[N << 1], sR[N << 1];

void Apply(int id, int lq, int rq){
	sL[id] = max(min(sL[id], rq), lq);
	sR[id] = max(min(sR[id], rq), lq);
}
void Shift(int id){
	Apply(id << 1, sL[id], sR[id]);
	Apply(id << 1 | 1, sL[id], sR[id]);
	sL[id] = 0;
	sR[id] = Inf;
}
void Query(int id, int l, int r, int lq, int rq, int L, int R){
	if(r <= L || R <= l) return ;
	if(l <= L && R <= r){
		Apply(id, lq, rq);
		return ;
	}
	Shift(id);
	int mid = (L + R) >> 1;
	Query(id << 1, l, r, lq, rq, L, mid);
	Query(id << 1 | 1, l, r, lq, rq, mid, R);
}
int ans[N];
void DFS(int id, int L, int R){
	if(L + 1 == R){
		//cerr << "# " << L << " ! " << sL[id] << ' ' << sR[id] << '\n';
		ans[L] = sL[id];
		return ;
	}
	int mid = (L + R) >> 1;
	Shift(id);
	DFS(id << 1, L, mid);
	DFS(id << 1 | 1, mid, R); 
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	fill(sR, sR + N*2, Inf);
	for(int i = 0; i < k; i++){
		Query(1, left[i], right[i] + 1, op[i] == 1 ? height[i] : 0, op[i] == 2 ? height[i] : Inf, 0, n);
	}
	DFS(1, 0, n);
	for(int i = 0; i < n; i++) finalHeight[i] = ans[i];
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 16768 KB Output is correct
2 Correct 13 ms 16896 KB Output is correct
3 Correct 17 ms 16768 KB Output is correct
4 Correct 24 ms 17152 KB Output is correct
5 Correct 16 ms 17152 KB Output is correct
6 Correct 16 ms 17152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 16768 KB Output is correct
2 Correct 207 ms 30460 KB Output is correct
3 Correct 247 ms 24284 KB Output is correct
4 Correct 625 ms 31948 KB Output is correct
5 Correct 390 ms 32540 KB Output is correct
6 Correct 349 ms 33172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 16768 KB Output is correct
2 Correct 13 ms 17024 KB Output is correct
3 Correct 13 ms 16768 KB Output is correct
4 Correct 17 ms 17152 KB Output is correct
5 Correct 21 ms 17152 KB Output is correct
6 Correct 22 ms 17152 KB Output is correct
7 Correct 11 ms 16768 KB Output is correct
8 Correct 208 ms 30456 KB Output is correct
9 Correct 233 ms 24312 KB Output is correct
10 Correct 593 ms 31940 KB Output is correct
11 Correct 382 ms 32452 KB Output is correct
12 Correct 423 ms 32952 KB Output is correct
13 Correct 11 ms 16768 KB Output is correct
14 Correct 218 ms 30392 KB Output is correct
15 Correct 44 ms 18296 KB Output is correct
16 Correct 580 ms 32080 KB Output is correct
17 Correct 383 ms 32376 KB Output is correct
18 Correct 363 ms 32368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 16768 KB Output is correct
2 Correct 13 ms 16896 KB Output is correct
3 Correct 12 ms 16768 KB Output is correct
4 Correct 17 ms 17152 KB Output is correct
5 Correct 16 ms 17152 KB Output is correct
6 Correct 16 ms 17152 KB Output is correct
7 Correct 11 ms 16768 KB Output is correct
8 Correct 225 ms 30456 KB Output is correct
9 Correct 218 ms 24280 KB Output is correct
10 Correct 594 ms 31736 KB Output is correct
11 Correct 408 ms 32256 KB Output is correct
12 Correct 353 ms 32632 KB Output is correct
13 Correct 11 ms 16760 KB Output is correct
14 Correct 198 ms 30456 KB Output is correct
15 Correct 53 ms 18296 KB Output is correct
16 Correct 629 ms 31952 KB Output is correct
17 Correct 373 ms 31864 KB Output is correct
18 Correct 354 ms 31608 KB Output is correct
19 Correct 813 ms 71676 KB Output is correct
20 Correct 810 ms 69112 KB Output is correct
21 Correct 813 ms 71676 KB Output is correct
22 Correct 791 ms 68960 KB Output is correct
23 Correct 812 ms 68788 KB Output is correct
24 Correct 808 ms 68868 KB Output is correct
25 Correct 846 ms 68984 KB Output is correct
26 Correct 802 ms 71416 KB Output is correct
27 Correct 801 ms 71480 KB Output is correct
28 Correct 794 ms 68856 KB Output is correct
29 Correct 804 ms 68600 KB Output is correct
30 Correct 796 ms 68728 KB Output is correct