dp套dp的板子题
#include#include #include #include using namespace std;void read(int &x){ char ch;bool ok; for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1; for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;}#define rg registerconst int mod=1e9+7;int ans[20],n,k,f[2][1<<15][3],a[1<<15],b[1<<15],s[1<<15][3],m;char ch[20],d[3]={'N','O','I'};int prepare(int s,int w){ memset(b,0,sizeof b); for(rg int i=1;i<=k;i++)a[i]=a[i-1]+((s>>(i-1))&1); for(rg int i=1;i<=k;i++){ if(d[w]==ch[i])b[i]=a[i-1]+1; else b[i]=max(a[i],b[i-1]); } int ans=0; for(rg int i=1;i<=k;i++)ans|=(b[i]-b[i-1])<<(i-1); return ans;}int get_size(int x){int ans=0;while(x)ans+=x&1,x>>=1;return ans;}int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}signed main(){ read(n),read(k),scanf("%s",ch+1),m=1<