daitouzero @ 2023-01-11 20:13:14
不开o2是AC的
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<cstring>
#include<iostream>
#include<bitset>
#define inf 0x7f7f7f7f
#define X 20005
#define ll long long
#define lowbit(x) x&(-x)
#define MOD 998244353
#define maxn 100050
using namespace std;
inline int Max(int a,int b) {return a>b?a:b;}
inline int Min(int a,int b) {return a<b?a:b;}
inline void Swap(int &a,int &b) {a=a^b;b=a^b;a=a^b;}
inline int scan()
{
register int x=0,f=0;
register char c=getchar();
while(c<'0') f|=(c=='-'),c=getchar();
while(c>='0') x=(x<<1)+(x<<3)+(c&15),c=getchar();
return f?-x:x;
}
inline void print(int x)
{
if(x/10) print(x/10);
putchar(x%10+48);
}
int map[200],dp[200][1<<10][1<<10],sum[1<<10],rightcase[10],cnt,n,m,ans=0;
int get1(int x)
{
int res=0;
while(x) {res++;x-=lowbit(x);}
return res;
}
inline bool check(int acase) {return ((!(acase&(acase<<1)))&&(!(acase&(acase<<2)))&&(!(acase&(acase>>1)))&&(!(acase&(acase>>2))));}
inline void init()
{
for (int i=0;i<(1<<m);i++)
if(check(i)) rightcase[++cnt]=i,sum[i]=get1(i);
}
int main()
{
n=scan();m=scan();
char temp;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cin>>temp;
map[i]=(map[i]<<1)+(temp=='H');
}
init();
for(int i=1;i<=n;i++)
for(int j=1;j<=cnt;j++)
for(int k=1;k<=cnt;k++)
for(int p=1;p<=cnt;p++)
{
if((!(rightcase[j]&rightcase[p]))&&(!(rightcase[j]&rightcase[k]))&&(!(rightcase[j]&map[i])))
dp[i][rightcase[j]][rightcase[k]]=Max(dp[i][rightcase[j]][rightcase[k]],dp[i-1][rightcase[k]][rightcase[p]]+sum[rightcase[j]]);
}
for(int i=1;i<=cnt;i++)
for(int j=1;j<=cnt;j++)
ans=Max(ans,dp[n][rightcase[i]][rightcase[j]]);
print(ans);
return 0;
}
by ForgotDream_CHN @ 2023-01-11 20:21:03
@daitouzero 你之前能对才有鬼呢
rightcase
开小啦!
by daitouzero @ 2023-01-11 20:25:13
%%%
by Hellsing_Alucard @ 2023-01-11 21:50:55
话说你们走两米就能说为什么要打字呢
by ForgotDream_CHN @ 2023-01-12 00:24:29
@rubish 机房大佬 orzzzzzz
by Hellsing_Alucard @ 2023-01-12 13:42:18
@ForgotDream_CHN%%%%