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> #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator