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 again !但我的边缘数据都OK<<<<<<<<

Posted by lengzhigang at 2009-08-24 08:19:10 on Problem 1573
错,你在哪?
我实在是找不到啊


#include<stdio.h>
int main()
{
  int b[100][2],row,col,sta,i,x,y,count,flag=1;
  char grid[10][12];
  while(scanf("%d%d%d",&row,&col,&sta))
  {
    if(row==0&&col==0&&sta==0) break;
	  x=sta-1;  y=0; count=0;
	for(i=0;i<row;i++)
	  scanf("%s",grid[i]);
     b[count][0]=x;b[count][1]=y; 
	 flag=1;
	while(flag)
	{   
	      count++;
	   switch(grid[y][x])
	   {
	    case'E':x=x+1;b[count][0]=x;b[count][1]=y;break;
	    case'W':x=x-1;b[count][0]=x;b[count][1]=y;break;
	    case'S':y=y+1;b[count][0]=x;b[count][1]=y;break;
	    case'N':y=y-1;b[count][0]=x;b[count][1]=y;break;
		
	   }

	   for(i=0;i<count;i++) 
	   {
	       if(b[count][0]==b[i][0]&&b[count][1]==b[i][1])
		   {  
		      printf("%d step(s) before a loop of %d step(s)\n",i,count-i);
			  flag=0;
			  break;
		   }
		   
	   }
	  
	  if(x<0||x>=col||y<0||y>=row)
	  { 
	   
	   printf("%d step(s) to exeit\n",count);
		  flag=0;
	   
	  }
	}
  }
  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