标签:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define N 1100
#define MOD 1000000007
#define met(a, b) memset(a, b, sizeof(a))
#define INF 0x3f3f3f3f
char G[N][N];
int dp[N][N];
int main()
{
int n;
while(scanf("%d", &n), n)
{
int i, j, i1, j1, Max=1;
met(G, 0);
met(dp, 0);
for(i=0; i<n; i++)
scanf("%s", G[i]);
for(i=0; i<n; i++)
for(j=0; j<n; j++)
{
if(i==0 || j==n-1)
{
dp[i][j] = 1;
continue;
}
i1=i, j1=j;
while(j1<n && i1>=0 && G[i1][j]==G[i][j1] )
i1--, j1++;
if((i-i1)>=dp[i-1][j+1]+1) dp[i][j] = dp[i-1][j+1] + 1;
else dp[i][j] = i-i1;
Max = max(Max, dp[i][j]);
}
printf("%d\n", Max);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/YY56/p/5456471.html