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 scau200630690218 at 2007-10-15 18:33:14 on Problem 2339
#include<iostream>
#include<cstring>
using namespace std;
#define N 10010
char grid_1[N][N];
char grid_2[N][N];
int r, c, d;
int i, j;
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
bool flag(int x, int y){
	return (x <= r && x >= 1 && y <= c && y >= 1);
}
void init(){
	for (i = 1; i <= r; i++)for (j = 1; j <= c; j++)cin >> grid_1[i][j];
}
void pr(){
	for (i = 1; i <= r; i++){
		for (j = 1; j <= c; j++)
			cout << grid_1[i][j];
		cout << endl;
	}
}
void copy(){
	for (i = 1; i <= r; i++)
		for (j = 1; j <= c; j++)
			grid_1[i][j] = grid_2[i][j];
}
void occupy(){
	int x, y, k;
	for (i = 1; i <= r; i++){
		for (j = 1; j <= c; j++){
			for (k = 0; k < 4; k++){
				x = i + dir[k][0];
				y = j + dir[k][1];
				if (flag(x, y)){
					if (grid_1[x][y] == 'R' && grid_1[i][j] == 'S' ||
						grid_1[x][y] == 'S' && grid_1[i][j] == 'P' ||
						grid_1[x][y] == 'P' && grid_1[i][j] == 'R'){
						grid_2[i][j] = grid_1[x][y];
						break;
					}
					else grid_2[i][j] = grid_1[i][j];
				}
			}
		}
	}
}	
int main(){
	int T;
	cin >> T;
	while (T--){
		cin >> r >> c >> d;
		init();
		while (d--){
			occupy();
			copy();
		}
		pr();
		if (T)cout << endl;
	}
	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