jiangby @ 2018-09-02 14:55:55
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<vector>
#include<deque>
#include<set>
#include<map>
#define N 100005
using namespace std;
int n,m,a[105];
int zt[105],gs[105],cnt;
int f[105][65][65];
void dfs(int y,int num,int g){
if(y>m){
zt[++cnt]=num>>(y-m-1);
gs[cnt]=g;
return;
}
dfs(y+1,num<<1,g);
dfs(y+3,(num<<1|1)<<2,g+1);
}
int main(){
scanf("%d%d",&n,&m);
dfs(1,0,0);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char x;
scanf("%c",&x);
a[i]<<=1;
if(x=='P')a[i]|=1;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=cnt;j++){
int x=zt[j];
if((x|a[i])!=a[i])continue;
for(int k=1;k<=cnt;k++){
int y=zt[k];
if((x&y))continue;
for(int l=1;l<=cnt;l++){
int z=zt[l];
if((x&z)||(y&z))continue;
f[i][j][k]=max(f[i][j][k],f[i-1][k][l]+gs[j]);
}
}
}
}
int maxx=0;
for(int i=1;i<=cnt;i++){
for(int j=1;j<=cnt;j++){
if(zt[i]&zt[j])continue;
maxx=max(f[n][i][j],maxx);
}
}
printf("%d",maxx);
return 0;
}
by HikariForever @ 2018-09-02 15:09:27
linux系统了解一下
by jiangby @ 2018-09-02 15:14:18
@四代目火影 所以我该怎么办啊