답안 #927082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927082 2024-02-14T08:43:43 Z Nurislam 벽 (IOI14_wall) C++14
0 / 100
141 ms 13936 KB
//~ #include "wall.h"
#include <bits/stdc++.h>
//~ #include "grader.cpp"

using namespace std;

#define pb push_back
#define ff first
#define ss second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
const int N = 2e6+5;
pii b[N*4]{};
int a[N]{};
void push(int i, int l, int r){
	if(l == r){
		if(b[i].ss == 0)return;
		if(b[i].ss == 2){
			a[l] = min(b[i].ff, a[l]);
		}else{
			a[l] = max(b[i].ff, a[l]);
		}
		b[i] = {0,0};
		return;
	}
	if(b[i] == pair<int,int>({0, 0}))return;
	b[i*2] = b[i];
	b[i*2+1] = b[i];
	b[i] = {0, 0};
}

void upd(int i, int l, int r, int tl, int tr, pii val){
	push(i, l, r);
	if(l > tr || r < tl || r < l)return;
	if(tl <= l && r <= tr){
		b[i] = val;
		push(i, l, r);
		return;
	}
	int m = (l+r)>>1;
	upd(i*2, l, m, tl, tr, val);
	upd(i*2+1, m+1, r, tl, tr, val);
	
}

int get(int i, int l, int r, int ps){
	push(i, l, r);
	if(l == r && l == ps)return a[ps];
	int m = (l+r)>>1;
	if(ps <= m)return get(i*2, l, m, ps);
	else return get(i*2+1, m+1, r, ps);
}

void buildWall(int n, int k, int op[], int l[], int r[], int h[], int finalHeight[]){
	
	for(int i = 0; i < k; i++){
		upd(1, 0, n-1, l[i], r[i], {h[i], op[i]});
		//~ for(int i = 0; i < n; i++){
			//~ finalHeight[i] = get(1, 0, n-1, i);
			//~ cout << a[i] << ' ';
		//~ }cout << '\n';
	}
	for(int i = 0; i < n; i++){
		finalHeight[i] = get(1, 0, n-1, i);
		//~ cout << a[i] << ' ';
	}
	//~ cout << '\n';
	return;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 1 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 107 ms 13936 KB Output is correct
3 Incorrect 141 ms 5204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -