标签:
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1000 + 10;
char a[maxn][maxn];
int dp[maxn][maxn],ans,n;
void func(int x,int y){
int maxl = min(x,n - y);
int i;
for(i = 0;i <= maxl;++i){
if(a[x - i][y] != a[x][y + i]) break;
}
if(i >= dp[x - 1][y + 1] + 1){
dp[x][y] = dp[x - 1][y + 1] + 1;
}else dp[x][y] = i;
if(dp[x][y] > ans) ans = dp[x][y];
}
int main(){
while(~scanf("%d",&n) && n){
for(int i = 1;i <= n ; ++i){
scanf("%s",a[i] + 1);
}
ans = 0;
for(int i = 1; i <= n ; ++i)
for(int j = n ;j > 0;--j)
func(i,j);
printf("%d\n",ans);
}
return 0;
}
[2016-03-29][HDU][2859][Phalanx]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/5346501.html