답안 #30478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30478 2017-07-23T15:22:10 Z inqr 벽 (IOI14_wall) C++14
컴파일 오류
0 ms 0 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=-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;
	if(u.l<=l&&r<=u.r){
		if(l!=r)st[stp*2+1]=st[stp*2+2]=st[stp];
		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(ql<=l&&r<=qr){
		if(l!=r) st[stp*2+1]=st[stp*2+2]=st[stp];
		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<k;i++){
		finalHeight[i]=que(i,i,0,n-1,0);
	}
  	return;
}

Compilation message

Compilation timeout while compiling wall