标签:
Description
Input
Output
Sample Input
Sample Output
#include<iostream> #include<cstring> #include<cmath> #include<cstdlib> #include<string> #include<algorithm> #include<cstdio> #include<queue> #include<vector> #include<set> #include<map> using namespace std; int n,ans,dp[105][105][8]; int dx[8] = {0, -1, 0, 1, -1, 1, 1, -1}; int dy[8] = {-1, 0, 1, 0, -1, -1, 1, 1}; char s[105][105]; int dfs(int x,int y,int dir) { if(dp[x][y][dir]!=-1) return dp[x][y][dir]; if(s[x+dx[dir]][y+dy[dir]]==‘.‘) { return dp[x][y][dir]=1+dfs(x+dx[dir],y+dy[dir],dir); } else return dp[x][y][dir]=1; } void cal(int x,int y,int d1,int d2) { ans=max(ans,dfs(x,y,d1)+dfs(x,y,d2)-1); } int main() { while(scanf("%d",&n)!=EOF) { if(n==0) break; ans=0; memset(s,0,sizeof(s)); memset(dp,-1,sizeof(dp)); for(int i=0;i<n;i++) scanf("%s",s[i]); for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(s[i][j]==‘.‘) { for(int k=0;k<4;k++) { cal(i,j,k%4,(k+1)%4); cal(i,j,4+(k%4),4+(k+1)%4); } } } } printf("%d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4434021.html