- 迎春舞会之集体舞
- 2018-07-27 21:47:14 @
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i=1;i<=n;i++)
#define REP(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define pos(x,y) (x+(y)*n)
const int N=100000+10;
const int inf=0x3f3f3f3f;
const ll mod=1000000007;
const double eps=1e-8;
int n;
string s;
int a[101][201];
int f[101][201][201];
int ans;
int main() {
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%d\n",&n);
FOR(i,n) {
getline(cin,s);
int cnt=0;
for (int j=0;j<s.size();j++) {
if (s[j]=='-') a[i][++cnt]=0;
else if (s[j]=='#') a[i][++cnt]=1;
}
}
FOR(i,n) {
FOR(j,2*(n+1-i)-1) {
if (j%2==1&&a[i][j]==0) {
f[i][j][1]=1;
ans=max(ans,1);
}
}
}
FOR(i,n) {
int len=2*(n+1-i)-1;
FOR(j,len) {
if (j%2==1&&a[i][j]==0) {
if (i>1&&a[i-1][j]==0&&j+2<=len+2&&a[i-1][j+1]==0&&a[i-1][j+2]==0) for (int k=n;k>=2;k--) {
if (f[i-1][j][k-1]&&f[i-1][j+2][k-1]) {
f[i][j][k]=1;
ans=max(ans,k);
break;
}
}
}
}
}
cout<<ans*ans<<endl;
return 0;
memset(f,0,sizeof f);
FOR(i,n) {
FOR(j,2*(n+1-i)-1) {
if (j%2==0&&a[i][j]==0) {
f[i][j][1]=1;
ans=max(ans,1);
}
}
}
for (int i=n;i>=1;i--) {
int len=2*(n+1-i)-1;
FOR(j,len) {
if (j%2==0&&a[i][j]==0) {
if (i<n&&a[i+1][j]==0&&j-2>=1&&a[i+1][j-1]==0&&a[i+1][j-2]==0) for (int k=n;k>=2;k--) {
if (f[i+1][j-2][k-1]&&f[i+1][j][k-1]) {
f[i][j][k]=1;
ans=max(ans,k);
break;
}
}
}
}
}
cout<<ans*ans<<endl;
return 0;
}
1 条评论
-
Goodhao LV 10 @ 2018-07-28 07:37:32
啊。。
我只给f记录了最大的k。。
- 1