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

跪求,why wa

Posted by majia8 at 2009-08-29 00:57:09 on Problem 3669
int g[500][500],it[250000],jt[250000],lvl[250000];
int vet[5][2]={{0,1},{1,0},{-1,0},{0,-1},{0,0}};
void main(){
	int t,i,k,a,b,top=1,low=0,f=0,ans=-1;
	scanf("%d",&t);
	memset(g,-1,sizeof(g));
	while(t--){
		scanf("%d%d%d",&a,&b,&k);
		for(i=0;i<5;i++)if(g[a+vet[i][0]][b+vet[i][1]]==-1||g[a+vet[i][0]][b+vet[i][1]]>k)g[a+vet[i][0]][b+vet[i][1]]=k;
	}
	if(g[0][0]==-1)ans=0;
	else while(top>low){
		for(k=0;k<4;k++){
			it[top]=it[low]+vet[k][0];
			jt[top]=jt[low]+vet[k][1];
			lvl[top]=lvl[low]+1;
			if(it[top]>=0&&jt[top]>=0){
				if(g[it[top]][jt[top]]==-1){f=1;ans=lvl[top];break;}
				if(lvl[top]<g[it[top]][jt[top]])top++; 
			}
		}
		low++;
		if(f)break;
	}
	printf("%d\n",ans);
}
wa了,写的很基础的广搜,不知有什么问题····

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