标签:路径 void pac cto gre 个数 ane include size
Tme Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18126 Accepted Submission(s): 11045
#include<iostream> #include<cstdio> #include<cmath> #include<map> #include<cstdlib> #include<vector> #include<set> #include<queue> #include<cstring> #include<string.h> #include<algorithm> #define INF 0x3f3f3f3f typedef long long ll; typedef unsigned long long LL; using namespace std; const int N = 1e6+10; const ll mod = 1e9+7; int t=0,flag=0; char s[26][26]; int visited[26][26]; int m,n; int _x[4]={0,1,-1,0}; int _y[4]={1,0,0,-1}; int ans; void DFS(int x,int y){ for(int t=0;t<4;t++){ int i=x+_x[t]; int j=y+_y[t]; if(i>=0&&j>=0&&visited[i][j]==0&&s[i][j]==‘.‘&&i<=n-1&&j<=m-1) { ans++; visited[i][j]=1; DFS(i,j); } } } int main(){ while(scanf("%d%d",&m,&n)!=EOF){ if(m==0&&n==0)break; memset(visited,0,sizeof(visited)); int ii,jj; int i,j; for(ii=0;ii<n;ii++){ for(jj=0;jj<m;jj++){ cin>>s[ii][jj]; if(s[ii][jj]==‘@‘){i=ii;j=jj;} } } ans=1; visited[i][j]=1; DFS(i,j); cout<<ans<<endl; } }
标签:路径 void pac cto gre 个数 ane include size
原文地址:http://www.cnblogs.com/Aa1039510121/p/6103158.html