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

为什么WA?

Posted by sunflowwer at 2006-08-09 16:28:13 on Problem 2386
#include <stdio.h>

int a,b;
char map[1000][1000];
int result[1000][1000];
void work(int p,int q,int r,int t)
{
     if(r>=0 && r<a && t>=0 && t<b)
		 if(map[r][t]=='W' && result[r][t])
			  result[p][q]=result[r][t];
}
int main()
{
     int s;
	 char message[1000];
	 int i,j;
	 scanf("%d%d",&a,&b);
	 for(i=0;i<a;i++)
		 for(j=0;j<b;j++)
	          result[i][j]=0;
	 for(i=0;i<a;i++){
	      scanf("%s",&message);
		  for(j=0;j<b;j++)
			  map[i][j]=message[j];
	 }
	 s=0;
	 for(i=0;i<a;i++)
		 for(j=0;j<b;j++)
			 if(map[i][j]=='W'){
			      work(i,j,i-1,j);
				  work(i,j,i-1,j-1);
				  work(i,j,i,j-1);
				  work(i,j,i+1,j-1);
				  work(i,j,i+1,j);
				  work(i,j,i-1,j+1);
				  work(i,j,i,j+1);
				  work(i,j,i+1,j+1);
				  if(!result[i][j])
					  result[i][j]=++s;
			 }
	printf("%d\n",s);
	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