Submission #889013

# Submission time Handle Problem Language Result Execution time Memory
889013 2023-12-18T15:24:46 Z BBart888 Wall (IOI14_wall) C++14
0 / 100
231 ms 82136 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN= 2e6+11;


int tmx[4*MAXN];
int tmn[4*MAXN];
pair<int,int> lazy[4*MAXN];


void pull_add(int x,int val)
{
	tmx[x] = max(tmx[x],val);
	tmn[x] = max(tmn[x],val);
	lazy[x].first = max(lazy[x].first,val);
	lazy[x].second = max(lazy[x].second,val);
	
}

void pull_dec(int x,int val)
{
	tmx[x] = min(tmx[x],val);
	tmn[x] = min(tmn[x],val);
	lazy[x].first = min(lazy[x].first,val);
	lazy[x].second = min(lazy[x].second,val);
}

void push(int x)
{
	if(lazy[x].first != -1e9)
	{
		pull_add(2*x,lazy[x].first);
		pull_add(2*x+1,lazy[x].first);
	}
	else if(lazy[x].second != 1e9)
	{
		pull_dec(2*x,lazy[x].second);
		pull_dec(2*x+1,lazy[x].second);
	}
	lazy[x] = {-1e9,1e9};
}


void upd(int v,int tl,int  tr,int l,int r,int type,int val)
{
	if(l > r)
		return;
	if(l == tl && tr ==r)
	{
			if(type == 1)
				pull_add(v,val);
			else
				pull_dec(v,val);
			return;
	}
	int tm =(tl+tr)/2;
	push(v);
	upd(2*v,tl,tm,l,min(r,tm),type,val);
	upd(2*v+1,tm+1,tr,max(l,tm+1),r,type,val);
	tmx[v] = max(tmx[2*v],tmx[2*v+1]);
	tmn[v] = min(tmn[2*v],tmn[2*v+1]);
}


int get(int v,int tl,int tr,int pos)
{
	if(tl == tr)
		return tmx[v];
	int tm =(tl+tr)/2;
	push(v);
	if(pos <= tm)
		return get(2*v,tl,tm,pos);
	else
		return get(2*v+1,tm+1,tr,pos);
}



void buildWall(int n,int k,int op[],int left[],
int right[],int height[],int finalHeight[])
{
	for(int i = 0;i<4*MAXN;i++)
		lazy[i] = {-1e9,1e9};
	
	for(int i =0;i<k;i++)
		{
			if(op[i] == 1)
				upd(1,0,MAXN,left[i],right[i],1,height[i]);
			else
				upd(1,0,MAXN,left[i],right[i],0,height[i]);
		}

	for(int i =0;i<n;i++)
		finalHeight[i] = get(1,0,MAXN,i);
		
	

}
/*

int main()
{
	cin.tie(0);
	cout.tie(0);
	
	
	
	
	upd(1,0,MAXN,1,5,1,6);
	upd(1,0,MAXN,4,5,0,3);
	
	
	
	for(int i =0;i<=10;i++)
		cout<<get(1,0,MAXN,i)<<" ";
			

	
	
	
	
	
	return 0;
}

*/
# Verdict Execution time Memory Grader output
1 Correct 15 ms 74332 KB Output is correct
2 Correct 14 ms 74588 KB Output is correct
3 Incorrect 13 ms 70236 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 74332 KB Output is correct
2 Correct 231 ms 82136 KB Output is correct
3 Incorrect 205 ms 73952 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 74328 KB Output is correct
2 Correct 15 ms 74588 KB Output is correct
3 Incorrect 13 ms 70236 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 74332 KB Output is correct
2 Correct 15 ms 74580 KB Output is correct
3 Incorrect 17 ms 70236 KB Output isn't correct
4 Halted 0 ms 0 KB -