shitbro @ 2019-01-20 17:51:10
求查错???
#include<string>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int ok[1025];
int num[1025];
int n,m;
int b[1025];
int f[105][1025][1025];//中间是上一行,最后是这一行
int main()
{
/*freopen(" ","r",stdin);
freopen(" ","w",stdout);*/
cin>>n>>m;
int cnt=0;
for(int i=0;i<(1<<m);i++)
{
if((i>>1)&i)continue;
if((i<<1)&i)continue;
if((i>>2)&i)continue;
if((i<<2)&i)continue;
int k=i;
cnt++;
while(k)
{
if(k&1)
num[cnt]++;
k=(k>>1);
}
ok[cnt]=i;
}
for(int i=1;i<=n;i++)
{
char a[105];
scanf("%s",a);
for(int j=0;j<m;j++)
{
if(a[j]=='H')
{
b[i]=(b[i]<<1)+1;
}
else
b[i]=(b[i]<<1);
}
}
for(int i=1;i<=cnt;i++)
{
if(ok[i]&b[1])continue;
f[1][0][i]=num[i];
}
for(int i=2;i<=n;i++)
{
for(int j=1;j<=cnt;j++)
{
if(ok[j]&b[i])continue;
for(int k=1;k<=cnt;k++)
{
if(ok[j]&ok[k])continue;
for(int t=1;t<=cnt;t++)
{
if(ok[j]&ok[t])continue;
if(ok[k]&ok[t])continue;
f[i][k][j]=max(f[i][k][j],f[i-1][t][k]+num[j]);
}
}
}
}
int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=cnt;j++)
{
for(int k=1;k<=cnt;k++)
{
ans=max(ans,f[i][j][k]);
}
}
}
cout<<ans;
/*fclose(stdin);
fclose(stdout);*/
return 0;
}
by Juanzhang @ 2019-01-20 18:23:42
不是妹子啊,走了走了
by shitbro @ 2019-01-20 18:29:42
@Juanzhang 崔哥看看呗
by andyli @ 2019-01-20 18:34:46
不是妹子啊,走了走了
by shitbro @ 2019-01-20 18:37:23
@andyli wow,you can not do this
by 花园Serena @ 2019-01-20 19:09:52
不是妹子啊,走了走了