답안 #52133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52133 2018-06-24T06:25:34 Z shoemakerjo 벽 (IOI14_wall) C++14
0 / 100
1153 ms 102860 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;
#define maxn 2000010
#define maxk 500010
int seg[maxn*4];
int lazy[maxn*4];
int lazyt[maxn*4];

int N, K;

void delaze(int ss, int se, int si) {
	if (lazy[si] == -1) {
		return;
	}
	if  (lazyt[si] == 1) { //these are maxes
		seg[si] = max(seg[si], lazy[si]);
	}
	else {
		seg[si] = min(seg[si], lazy[si]);
	}
	if (ss != se) {
		for (int d = 1; d <= 2; ++d) {
			if (lazyt[si*2+d] == -1) {
				lazy[si*2+d] = lazy[si];
				lazyt[si*2+d] = lazyt[si];
			}
			else {
				if (lazyt[si] == 1) {
					if (lazyt[si*2+d] == 1) {
						lazy[si*2+d] = max(lazy[si*2+d], lazy[si]);
					}
					else {
						//there is a min there, and then we take the max with the new thing
						//basically if the max is below the min we do nothing, otherwise we do the max only
						if (lazy[si] >= lazy[si*2+d]) {
							lazy[si*2+d] = lazy[si];
							lazyt[si*2+d] = lazyt[si];
						}
					}
				}
				else {
					if (lazyt[si*2+d] == 2) {
						lazy[si*2+d] = min(lazy[si*2+d], lazy[si]);
					}
					else {
						//there is a max there, and then we take the min
						if (lazy[si] <= lazy[si*2+d]) {
							lazy[si*2+d] = lazy[si];
							lazyt[si*2+d] = lazyt[si];
						}
					}
				}
			}
		}
		
		
	}

	lazy[si] = lazyt[si] = -1;

}


void up(int us, int ue, int type, int h, int ss, int se, int si) {
	delaze(ss, se, si);
	if (us > ue || ss > se || us > se || ue < ss) return;
	if (us <= ss && se <= ue) {
		lazy[si] = h;
		lazyt[si] = type;
		delaze(ss, se, si);
		return;
	}
	int mid = (ss+se)/2;
	up(us, ue, type, h, ss, mid, si*2+1);
	up(us, ue, type, h, mid+1, se, si*2+2);

}

void update(int us, int ue, int type, int h) {
	up(us, ue, type, h, 0, N-1, 0);
}

int qu(int spot, int ss, int se, int si) {
	delaze(ss, se, si);
	if (ss == se) return seg[si];
	int mid = (ss+se)/2;
	if (spot <= mid) return qu(spot, ss, mid, si*2+1);
	return qu(spot, mid+1, se, si*2+2);
}

int query(int spot) {
	return qu(spot, 0, N-1, 0);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	fill(seg, seg+maxn*4, 0);
	fill(lazy, lazy+maxn*4, -1);
	fill(lazyt, lazyt+maxn*4, -1);
	N = n;
	K = k;

	//do the queries
	for (int i = 0; i < k; i++) {
		update(left[i], right[i], op[i], height[i]);
	}
	for (int i = 0; i  < n; i++) {
		finalHeight[i] = query(i);
	}
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 94200 KB Output is correct
2 Correct 77 ms 94324 KB Output is correct
3 Incorrect 93 ms 94384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 94384 KB Output is correct
2 Correct 278 ms 102228 KB Output is correct
3 Correct 415 ms 102228 KB Output is correct
4 Incorrect 1153 ms 102860 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 102860 KB Output is correct
2 Correct 77 ms 102860 KB Output is correct
3 Incorrect 84 ms 102860 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 102860 KB Output is correct
2 Correct 76 ms 102860 KB Output is correct
3 Incorrect 78 ms 102860 KB Output isn't correct
4 Halted 0 ms 0 KB -