답안 #30486

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30486 2017-07-23T20:31:12 Z inqr 벽 (IOI14_wall) C++14
0 / 100
19 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;
	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);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 95768 KB Output isn't correct
2 Halted 0 ms 0 KB -