Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求测试数据!! 帮忙看一下哪里错了 ,它给的数据都能过 而且自己想的也能过,就是WA啊!非常感谢#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator