传送门

Solution

裸区间DP

Code

#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define F(i,a,b) for(register int i=(a);i<=(b);i++)
using namespace std; inline int read() {
int x=0,f=1;char c=getchar();
while(!isdigit(c)) {if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
} int tot,len;
map <char,int> M;
char str[]="!WING",ch[300];
int num[5],sc[300][3],f[300][300][5]; int main() {
F(i,1,4) M[str[i]]=i;
F(i,1,4) num[i]=read();
F(i,1,4) F(j,1,num[i]) sc[++tot][0]=i,scanf("%s",ch+1),sc[tot][1]=M[ch[1]],sc[tot][2]=M[ch[2]];
scanf("%s",ch+1);len=strlen(ch+1);
F(i,1,len) f[i][i][M[ch[i]]]=1;
F(L,1,len) F(i,1,len-L+1) {
int j=i+L-1;
F(k,i,j-1) F(x,1,tot)
f[i][j][sc[x][0]]|=f[i][k][sc[x][1]]&f[k+1][j][sc[x][2]];
} // F(i,1,len) F(j,i,len) F(k,1,4) cout<<i<<" "<<j<<" "<<k<<" "<<f[i][j][k]<<endl;
bool flag=0; F(i,1,4) if(f[1][len][i]) putchar(str[i]),flag=1;
if(!flag) puts("The name is wrong!");
return 0;
}

最新文章

  1. Hadoop技巧(03):HostName命名带来的问题
  2. Cannot assign requested address出现的原因及解决方案
  3. HDU 3833 YY&#39;s new problem ()
  4. (转)Ratchet教程:Buttons组件
  5. 用Zend Studio12 导入在workspace中的项目
  6. sicily 1027 MJ, Nowhere to Hide 字符串匹配与排序
  7. python dict{}和set([])
  8. php+mysql非缓冲查询(如何循环大数组)
  9. [转]mysql自动定时备份数据库的最佳方法-支持windows系统
  10. Expert for SQL Server 诊断系列
  11. Blend4开发:会飞的小鸟
  12. RecyclerView 配合 DiffUtil,好用到飞起
  13. Redis入门 (CentOS7 + Redis-3.2.1)
  14. redis 系列5 数据结构之字典(上)
  15. iOS 字体下载
  16. Mybatis运行错误:信息: SQLErrorCodes loaded: [DB2, Derby, H2, HDB, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
  17. kafka入门1:安装及配置
  18. df值自由度学习[转载]
  19. RAID廉价磁盘冗余阵列介绍
  20. sshpass使用

热门文章

  1. [Angular] Using ngTemplateOutlet to create dynamic template
  2. ctags的基本操作总结
  3. Java 构造时成员初始化的陷阱
  4. Java 获取随机日期
  5. leetcode String相关
  6. PCB决策引擎:多维决策表转决策树
  7. lodop多打印一页白纸
  8. Gym - 101981M The 2018 ICPC Asia Nanjing Regional Contest M.Mediocre String Problem Manacher+扩增KMP
  9. C#,Java,MD5加密对等实现
  10. 编写linux 命令行实用工具 shell命令