今日得分:20+100+39(终于在考场上A题了)
T1
题目大意:给你一个长度为n的01字符串,定义(A*k)(k>=2)为S=A+A+…+A(k个A)的合法压缩,可压缩一个合法压缩串,两个合法压缩串连在一起也是一个合法压缩串。求给定01字符串的子集(与原串的与等于自身的串)的合法压缩方案之和对998244353取模的结果。n<=100。
题解:每次枚举最后一段压缩的串,记忆化搜索强制全压缩的串和不强制全压缩的串,dp即可。状态数可以证明不是很多(上界是O(n^3+2^(n/8)),但这个上界非常非常的松)。
AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<ctime>
#include<map>
using namespace std;
inline int re_ad()
{
int x=0,f=1;char ch=getchar();
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=x*10+(ch^48),ch=getchar();
return x*f;
}
const int mo=998244353;
string s;
map<string,int> mp[2];
int f(int now,string x)
{
if(mp[now][x])return mp[now][x];
register int i,j,k,n=x.length(),ret=0;//cout<<now<<" "<<n<<" "<<x<<endl;
if(now)
{
for(i=0;i<n;++i)ret=(ret+1ll*f(1,x.substr(0,i))*f(0,x.substr(i,n))%mo)%mo;
return mp[now][x]=ret;
}
else
{
for(i=1;i<n;++i)
{
if(n%i)continue;
string t="";for(j=0;j<i;++j)t+='1';
for(j=0;j<n;j+=i)
for(k=0;k<i;++k)if(x[j+k]=