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

如果不看discuss 绝对不知道 数据范围100绝对是个坑 1000真的能过

Posted by LSLIAOWEI at 2016-07-20 16:21:50 on Problem 2386
#include <stdio.h>
#define N 1000	//据说数据这里有个坑 开成1000就过了 如果过了就真的有个坑
char arr[N][N];
int r, l, ans;

void dfs(int x, int y)
{
	int i, j;
	int dx, dy;
	int nx, ny;
	arr[x][y] = '.';

	for(dx=-1; dx<=1; dx++)
		for(dy=-1; dy<=1; dy++)
		{
			nx = x + dx;
			ny = y + dy;
			if(arr[nx][ny] == 'W' && nx>=0 && nx<r && ny>=0 && ny<l)
				dfs(nx, ny);
		}
	return ;

}

int main()
{
	int i, j, k;
	scanf("%d %d", &r, &l);
	for(i=0; i<r; i++)
		//for(j=0; j<l; j++)	//我只想说为何用%c 样例输出就是8
		//	scanf("%c", &arr[i][j]);  //用%s 样例输出就是3 
			scanf("%s", arr[i]);

	for(i=0; i<r; i++)
		for(j=0; j<l; j++)
			if(arr[i][j] == 'W')
			{
				dfs(i, j);
				ans++;
			}
	printf("%d\n", ans);

	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