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 200609020331 at 2008-07-31 16:47:05 on Problem 2339
#include<iostream>
using namespace std;
int main()
{
	char grid[120][120];
   char grid2[120][120];
	int t,i,j,r,c,day;
	scanf("%d",&t);
	while(t>0)
	{
	memset(grid2,'0',sizeof(grid2));
		cin>>r>>c>>day;
		for(i=0;i<r;i++)
			scanf("%s",grid[i]);
		for(i=0;i<r;i++) 
		{
			for(j=0;j<c;j++)
				grid2[i][j]=grid[i][j];
		}
		while(day>0)
		{
			
			for(i=0;i<r;i++)
			{
				for(j=0;j<c;j++)
				{
					if( i-1>=0 && grid[i][j]=='R' && grid[i-1][j]=='S')
						grid2[i-1][j]='R';
					 if(i+1<r && grid[i][j]=='R' && grid[i+1][j]=='S')
						grid2[i+1][j]='R';
					 if( j-1>=0 && grid[i][j]=='R' && grid[i][j-1]=='S')
						grid2[i][j-1]='R';
					 if(j+1<c && grid[i][j]=='R' && grid[i][j+1]=='S')
						grid2[i][j+1]='R';
					 if(i-1>=0 && grid[i][j]=='S' && grid[i-1][j]=='P')
						grid2[i-1][j]='S';
				    if( i+1<r && grid[i][j]=='S' && grid[i+1][j]=='P')
						grid2[i+1][j]='S';
					 if(j-1>=0 && grid[i][j]=='S' && grid[i][j-1]=='P')
						grid2[i][j-1]='R';
					 if(j+1<c && grid[i][j]=='S' && grid[i][j+1]=='P')
						grid2[i][j+1]='S';
				    if(i-1>=0 && grid[i][j]=='P' && grid[i-1][j]=='R')
						grid2[i-1][j]='P';
					 if(i+1<r && grid[i][j]=='P' && grid[i+1][j]=='R')
						grid2[i+1][j]='P';
					 if(j-1>=0 && grid[i][j]=='P' && grid[i][j-1]=='R')
						grid2[i][j-1]='P';
					 if(j+1<c && grid[i][j]=='P' && grid[i][j+1]=='R')
						grid2[i][j+1]='P';
				}
			}
			for(i=0;i<r;i++) 
			{
				for(j=0;j<c;j++)
					grid[i][j]=grid2[i][j];
			}
			day--;
		}
		for(i=0;i<r;i++)
		{
			for(j=0;j<c;j++)
				printf("%c",grid2[i][j]);
			printf("\n");
		}
		if(t>1)
		printf("\n");
		t--;
	}
	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