답안 #789454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
789454 2023-07-21T12:04:31 Z OrazB 벽 (IOI14_wall) C++14
8 / 100
3000 ms 13892 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair <int, int>
#define ff first
#define ss second

const int N = 3e6;
const int inf = 1e9+7;
int NP, q, t[4*N][2];
pii lazy[4*N];

// void F(int l, int r, int idx){
// 	if (lazy[idx].ff == 0) return;
// 	if (lazy[idx].ff == 1){
// 		t[idx][0] = max(t[idx][0], lazy[idx].ss);
// 		t[idx][1] = max(t[idx][1], lazy[idx].ss);
// 	}else{
// 		t[idx][1] = min(t[idx][1], lazy[idx].ss);
// 		t[idx][0] = min(t[idx][0], lazy[idx].ss); 
// 	}
// 	if (l != r){
// 		lazy[idx<<1] = lazy[idx];
// 		lazy[idx<<1|1] = lazy[idx];
// 	}
// 	lazy[idx].ff = 0;
// }

void upd(int tp, int u, int v, int h, int l = 1, int r = NP, int idx = 1){
	// F(l, r, idx);
	if (l > v or r < u) return;
	if (u <= l and r <= v){
		if (tp == 1){
			t[idx][0] = max(t[idx][0], h);
			t[idx][1] = max(t[idx][1], h);
		}else{
			t[idx][1] = min(t[idx][1], h);
			t[idx][0] = min(t[idx][0], h); 
		}
		if (l == r) return;
		// F(l, r, idx);
		// return;
	}
	int md = (l+r)>>1;
	upd(tp, u, v, h, l, md, idx<<1);
	upd(tp, u, v, h, md+1, r, idx<<1|1);
}

int tap(int pos, int l = 1, int r = NP, int idx = 1){
	// F(l, r, idx);
	if (l == r) return t[idx][0];
	int md = (l+r)>>1;
	if (pos <= md) return tap(pos, l, md, idx<<1);
	return tap(pos, md+1, r, idx<<1|1);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	NP = n;
	for (int i = 1; i <= 4*n; i++) t[i][1] = inf;
	for (int i = 0; i < k; i++){
		upd(op[i], left[i]+1, right[i]+1, height[i]);
	}
	for (int i = 0; i < n; i++) finalHeight[i] = tap(i+1);
}

// int main ()
// {
// 	ios::sync_with_stdio(false);
// 	cin.tie(0);
// 	cin >> n >> q;
// 	for (int i = 1; i <= 4*n; i++) t[i][1] = inf;
// 	while(q--){
// 		int tp, l, r, h;
// 		cin >> tp >> l >> r >> h;
// 		upd(tp, l+1, r+1, h);
// 	}
// 	for (int i = 1; i <= n; i++) cout << tap(i) << " ";
// }	
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 117 ms 816 KB Output is correct
5 Correct 120 ms 804 KB Output is correct
6 Correct 119 ms 808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 119 ms 8640 KB Output is correct
3 Execution timed out 3050 ms 4684 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 117 ms 808 KB Output is correct
5 Correct 119 ms 820 KB Output is correct
6 Correct 119 ms 804 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 112 ms 13880 KB Output is correct
9 Execution timed out 3089 ms 7888 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 324 KB Output is correct
4 Correct 116 ms 808 KB Output is correct
5 Correct 119 ms 836 KB Output is correct
6 Correct 124 ms 848 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 131 ms 13892 KB Output is correct
9 Execution timed out 3065 ms 7932 KB Time limit exceeded
10 Halted 0 ms 0 KB -