-
P - Phalanx
- HDU - 2859
-
#include<iostream> #include<cstring> using namespace std; #define inf 0x3f3f3f3f #define maxn 2111 char mmp[maxn][maxn]; int dp[maxn][maxn],n; int main() { while(cin>>n) { if(!n) break; memset(dp,0,sizeof(dp)); for(int i=0; i<n; i++) cin>>mmp[i]; int ans=0; for(int i=0; i<n; i++) for(int j=0; j<n; j++) { if(i==0||j==n-1) dp[i][j]=1; else { int cnt1=i; int cnt2=j; while(cnt1>=0&&cnt2<n&&mmp[i][cnt2]==mmp[cnt1][j]) { cnt1--; cnt2++; } dp[i][j]=min(dp[i-1][j+1]+1,min(i-cnt1,cnt2-j)); } ans=max(dp[i][j],ans); } cout<<ans<<endl; } return 0; }
P - Phalanx -坐标DP
最新推荐文章于 2021-05-25 20:52:18 发布