Submission #30485

# Submission time Handle Problem Language Result Execution time Memory
30485 2017-07-23T20:29:49 Z inqr Wall (IOI14_wall) C++14
0 / 100
23 ms 95768 KB
#include "wall.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define pii pair < int , int >
#define DB printf("debug\n");
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define all(x) x.begin() , x.end()
using namespace std;
int N,K;
//add 1 erase 2
struct node{
	int a,e,l;
	node(){a=-1,e=1e9,l=-1;}
};
struct up{
	int l,r,v,t;
};
node st[8000005];
void merge(node &nod,up &u){
	if(nod.l==-1){// nod yapilmamis
		if(u.t==1){// update add
			nod.a=u.v;
			nod.l=1;
		}
		else{
			nod.e=u.v;
			nod.l=2;
		}
	}
	if(u.t==1){// udate add
		if(nod.l==1){// node last add
			if(nod.a<u.v){// u add > node add
				nod.a=u.v;
			}
			else return;// u add < node add
		}
		else{//node last erase
			if(nod.e<u.v){// u add > node erase
				nod.l=1;
				nod.a=u.v;
			}
			else return;// u add < node erase
		}
	}
	else{// udate erase
		if(nod.l==1){//node last add
			if(u.v<nod.a){// u erase < node add
				nod.l==2;
				nod.e=u.v;
			}
			else return;
		}
		else{//node last erase
			if(u.v<nod.e){// u erase < node erase
				nod.e=u.v;
			}
			return;
		}
	}
}
void stup(up u,int l,int r,int stp){
	if(l>r||u.r<l||r<u.l)return;
	printf("ul=%d ur=%d uv=%d ut=%d l=%d r=%d stp=%d\n",u.l,u.r,u.v,u.t,l,r,stp);
	if(st[stp].l!=-1&&l!=r)st[stp*2+1]=st[stp*2+2]=st[stp];
	if(u.l<=l&&r<=u.r){
		merge(st[stp],u);
		return;
	}
	int m=(l+r)/2;
	stup(u,l,m,stp*2+1);stup(u,m+1,r,stp*2+2);
}
int que(int ql,int qr,int l,int r,int stp){
	if(l>r||qr<l||r<ql)return -1;
	if(st[stp].l!=-1&&l!=r)st[stp*2+1]=st[stp*2+2]=st[stp];
	if(ql<=l&&r<=qr){
		if(st[stp].l==1)return st[stp].a;
		else return st[stp].e;
	}
	int m=(l+r)/2;
	return max(que(ql,qr,l,m,stp*2+1),que(ql,qr,m+1,r,stp*2+2));
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	N=n,k=K;
	printf("%d\n",K);
	DB
	for(int i=0;i<k;i++){
		up u;u.l=left[i],u.r=right[i],u.v=height[i],u.t=op[i];
		stup(u,0,n-1,0);
	}
	for(int i=0;i<n;i++){
		finalHeight[i]=que(i,i,0,n-1,0);
	}
}

Compilation message

wall.cpp: In function 'void merge(node&, up&)':
wall.cpp:54:10: warning: statement has no effect [-Wunused-value]
     nod.l==2;
          ^
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -