ZOJ1610【未完成】

以下代码是错的,仅用于存储而用

#include<iostream>
#include<cstdio>
#include<cstring>
const int maxn=8000+10;
#define mid ((s+t)>>1)  
#define ls h<<1,s,mid  
#define rs h<<1|1,mid+1,t 
using namespace std;
struct node{
	int c,sc,tc;
};
node a[maxn<<2];
int sum[maxn];
void init(int h,int s,int t ){
	if(s==t){
		a[h].c=10000;a[h].sc=a[h].tc=10000;
	}else{
		init(ls);
		init(rs);
		a[h].c=10000;a[h].sc=a[h].tc=10000;
	}

}
void ts(int h,int s,int t,int L,int R,int ys){
	if(L<=s && t<=R){
		a[h].c=ys;a[h].sc=a[h].tc=ys;
	}else{
		if(a[h].c>=0){
			a[h<<1].c=a[h<<1|1].c=a[h].c;
			a[h].c=-1;
		}
		if(L<=mid)ts(ls,L,R,ys);
		if(mid<R)ts(rs,L,R,ys);			
		a[h].sc=a[h<<1].sc;a[h].tc=a[h<<1|1].tc;	
	}
}
void dfs(int h,int s,int t){
	if(s<t){
		if(a[h].c!=-1){
			a[h<<1].c=a[h<<1|1].c=a[h].c;			
		}
		dfs(ls);
		dfs(rs);
	}
}
void cal(int h,int s,int t){
	printf("%d %d %d %d\n",h,a[h].c,s,t);
	if((s==t)){
		sum[a[h].c]++;		
	}
	else{
		cal(ls);
		cal(rs);
		if(a[h<<1].tc==a[h<<1|1].sc)sum[a[h<<1].tc]--;
	}
}
int main(){
	int i,j,k,m,n,x,y,z;
	while(scanf("%d",&n)!=EOF){
		memset(sum,0,sizeof(sum));
		init(1,1,6);
		for(i=1;i<=n;i++){
			scanf("%d%d%d",&x,&y,&z);			
			ts(1,1,4,x+1,y,z);
		}
		cout<<endl;
		dfs(1,1,6);
		cal(1,1,6);
		for(i=0;i<=8000;i++)
			if(sum[i])printf("%d %d\n",i,sum[i]);
		
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值