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

【求助】给点测试数据吧……用了题目的数据和自己的数据都正确……

Posted by luyao1103 at 2010-10-19 12:55:29 on Problem 2386
#include <iostream>
#include <string>
using namespace std;
int index =0;//sign the number of the pools
string m[102];
char clour[101][101];

void DFSVist(int i, int j)
{
	clour[i][j] = 1;
	for (int n =j-1;n<=j+1;++n)
	{
		for (int k = i-1;k<=i+1;++k)
		{
			if(m[k][n]=='W' && !clour[k][n])
				DFSVist(k,n);
		}
	}
	clour[i][j] = 2;
}

int main()
{
	int N,M;
	cin>>N>>M;
	for(int i= 0;i<102;++i)
		m[i] = string(100,'.');
	string temp;

	for(int i = 1;i<=N;++i){
		m[i] = ".";
		cin>>temp;
		m[i]+=temp;
		m[i] += ".";
	}
	for (int i = 1;i<=N;++i)
	{
		for (int j =1;j<=M;++j)
		{
			clour[i][j] = 0;
		}
	}
	for (int i = 1;i<N;++i)
	{
		for (int j =1;j<M;++j)
		{
			if(m[i][j] == 'W' && !clour[i][j]){
				DFSVist(i,j);
				++index;
			}
		}
	}
	cout<<index<<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