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 Oiprocs at 2010-08-09 10:52:47 on Problem 1154 and last updated at 2010-08-09 10:53:27
#include<iostream>
#include<fstream>
using namespace std;
char station[100][100];
int letter[26]={0};
int l=0,m=0;
int R,S;
int DFS(int i,int j)
{
	if(i>=0&&i<R&&j>=0&&j<S&&letter[station[i][j]-'A']==0)
	{
		letter[station[i][j]-'A']=1;
		l++;
		DFS(i,j-1);
		DFS(i,j+1);
		DFS(i-1,j);		
		DFS(i+1,j);
		letter[station[i][j]-'A']=0;
		l--;
	}
	else if(i<0||i>=R||j<0||j>=S)
		m=l>m?l:m;
	return m;	
}
int main()
{
	//ifstream cin("data.txt");
	memset(station,0,sizeof(char)*10000);	
	cin>>R>>S;
	for(int i=0;i<R;i++)
		for(int j=0;j<S;j++)
			cin>>station[i][j];
	cout<<DFS(0,0);
	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