Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

本机AC提交TLE

Posted by hzq84621 at 2015-05-16 07:57:21 on Problem 2434
RT,最大数据本机0.30s过,总用时0.72s,提交TLE
#include<cstdio>
using namespace std;
int a[9][9],tem,b1,b2,n,t,x,y,time;
bool init(int xx,int yy){
	if (xx>4)return false;
	if (yy>4)return false;
	if (xx<-4)return false;
	if (yy<-4)return false;
	return true;
}
int wz(int xx){
	if (xx>b2)return 2;
	if (xx<b1)return 0;
	return 1;
}
void cover(int x,int y,int t,int jj){
	int k=wz(x);
	for (int i=0;i<t;i++){
		int xx=x+t-i;int yy=y+i;
		if ((k==0)&&(wz(xx)>0))xx=2*b1-1-xx;
		if (k==1){
			xx=x+(t-i)%((b2-b1-1)*2);
			if (xx>=b2)xx=b2-(xx+1-b2);
			if (xx<=b1)xx=b1+(b1-xx+1);
		}
		if (init(xx,yy))a[xx+4][yy+4]+=jj;
		xx=x+i;yy=y-t+i;
		if ((k==0)&&(wz(xx)>0))xx=2*b1-1-xx;
		if (k==1){
			xx=x+i%((b2-b1-1)*2);
			if (xx>=b2)xx=b2-(xx+1-b2);
			if (xx<=b1)xx=b1+(b1-xx+1);
		}
		if (init(xx,yy))a[xx+4][yy+4]+=jj;
		xx=x-t+i;yy=y-i;
		if ((k==2)&&(wz(xx)<2))xx=2*b2-xx+1;
		if (k==1){
			xx=x-(t-i)%((b2-b1-1)*2);
			if (xx<=b1)xx=b1+(b1-xx+1);
			if (xx>=b2)xx=b2-(xx+1-b2);
		}
		if (init(xx,yy))a[xx+4][yy+4]+=jj;
		xx=x-i;yy=y+t-i;
		if ((k==2)&&(wz(xx)<2))xx=2*b2-xx+1;
		if (k==1){
			xx=x-i%((b2-b1-1)*2);
			if (xx<=b1)xx=b1+(b1-xx+1);
			if (xx>=b2)xx=b2-(xx+1-b2);
		}
		if (init(xx,yy))a[xx+4][yy+4]+=jj;
	}
}
int main(){
	freopen("waves.in","r",stdin);
	freopen("waves.out","w",stdout);
	scanf("%d%d%d%d",&n,&b1,&b2,&t);
	if (b2<b1){
		tem=b1;
		b1=b2;
		b2=tem;
	}
	for (int i=1;i<=n;i++){
		scanf("%d%d%d",&x,&y,&time);
		if (time>t)continue;
		if (time==t){
			if (init(x,y))a[x+4][y+4]++;
			continue;
		}
		if (t-time==1){
			cover(x,y,1,1);
			continue;
		}
		if (t-time==2){
			cover(x,y,2,1);
			if (init(x,y))a[x+4][y+4]--;
			continue;
		}
		cover(x,y,t-time,1);
		cover(x,y,t-time-2,-1);
	}
	for (int i=8;i>=0;i--){
		for (int j=0;j<=8;j++)if ((j==b1+4)||(j==b2+4))printf("X");
			else if (a[j][i]==0)printf("-");
				else if (a[j][i]>0)printf("*");
					else printf("o");
		printf("\n");
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator