Submission #927084

# Submission time Handle Problem Language Result Execution time Memory
927084 2024-02-14T08:46:20 Z Nurislam Wall (IOI14_wall) C++14
0 / 100
128 ms 8200 KB
//~ #include "wall.h"
#include <bits/stdc++.h>
//~ #include "grader.cpp"

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define ll long long
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
const int N = 2e6+5;
pii b[N*4]{};
ll a[N]{};
void push(ll i, ll l, ll 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] == pii({0, 0}))return;
	b[i*2] = b[i];
	b[i*2+1] = b[i];
	b[i] = {0, 0};
}

void upd(ll i, ll l, ll r, ll tl, ll 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;
	}
	ll m = (l+r)>>1;
	upd(i*2, l, m, tl, tr, val);
	upd(i*2+1, m+1, r, tl, tr, val);
	
}

int get(ll i, ll l, ll r, ll ps){
	push(i, l, r);
	if(l == r && l == ps)return a[ps];
	ll 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;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 2 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 105 ms 8200 KB Output is correct
3 Incorrect 128 ms 6884 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 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 -