Submission #237871

# Submission time Handle Problem Language Result Execution time Memory
237871 2020-06-09T07:06:30 Z Fasho Wall (IOI14_wall) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t,tree[6*N];
lli lazy[N];

void push(ll ind,int l,int r)
{
	if(lazy[ind].se==1)
		tree[ind]=max(tree[ind],lazy[ind].fi);
	
	if(lazy[ind].se==2)
		tree[ind]=min(tree[ind],lazy[ind].fi);
	if(l!=r)
	{
		int mid=(l+r)/2;
		push(ind*2,l,mid);
		push(ind*2+1,mid+1,r);
		lazy[ind*2]=lazy[ind];
		lazy[ind*2+1]=lazy[ind];
	}
	lazy[ind]={0,0};
}
ll query(int ind,int l,int r,int a)
{
	if(l>a || r<a)
		return 0;
	if(l==r)
		return a;
	int mid=(l+r)/2;
	if(mid<=a)
		return query(ind*2,l,mid,a);
	return query(ind*2+1,mid+1,r,a);

}

void upd(int ind,int l,int r,int a,int b,ll x,int typ)
{
	if(l>b || r<a)
		return;
	push(ind,l,r);
	if(l>=a && r<=b)
	{
		lazy[ind]={x,typ};
		push(ind,l,r);
		return;
	}
	int mid=(l+r)/2;
	upd(ind*2,l,mid,a,b,x,typ);
	upd(ind*2+1,mid+1,r,a,b,x,typ);
	return;
}

// void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){

	fo(i,0,k-1)
		upd(1,1,n,left[i]+1,right[i],height[i]+1,op[i]);

	fo(i,0,n-1)
		finalHeight[i]=query(1,1,n,i);
	return;
}




// int main()
// {
// 	fast;

// }

# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -