长度小于 10 是关键信息~

#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 1000000
#define setIO(s) freopen(s".in","r",stdin)
using namespace std;
struct Node {
int ch[27],end,len;
}t[N];
int n,m,tot,f[N];
char S[N];
void insert(int i) {
int rt=0,len=strlen(S+1),j;
for(j=len;j>=1;--j) {
if(!t[rt].ch[S[j]-'a']) t[rt].ch[S[j]-'a']=++tot;
t[t[rt].ch[S[j]-'a']].len=t[rt].len+1;
rt=t[rt].ch[S[j]-'a'];
}
t[rt].end=1;
}
int main() {
int i,j;
// setIO("input");
scanf("%d%d",&n,&m);
for(i=1;i<=n;++i)
scanf("%s",S+1),insert(i);
f[0]=1;
for(int cas=1;cas<=m;++cas) {
scanf("%s",S+1);
int len=strlen(S+1);
for(i=1;i<=len;++i) {
int p=0;
f[i]=0;
for(j=i;j>=1;--j) {
p=t[p].ch[S[j]-'a'];
if(!p) break;
if(t[p].end) f[i]|=f[j-1];
}
}
int MX=0;
for(i=1;i<=len;++i) {
if(f[i]) {
MX=i;
}
}
printf("%d\n",MX);
}
return 0;
}

  

最新文章

  1. ASP.NET将文件写到另一服务器
  2. 【SpringMVC】SpringMVC系列9之Model数据返回到View
  3. Android设置背景图像重复【整理自网络】
  4. c# List集合排序
  5. 手机PC监听用户复制内容
  6. Intellij Error:Cannot build Artifact &#39;XXX:war exploded&#39; because it is included into a circular dependency
  7. PGM:部分有向模型之条件随机场与链图模型
  8. stark组件的分页,模糊查询,批量删除
  9. Hystrix系列-5-Hystrix的资源隔离策略
  10. C++类中一个构造函数调用另一个构造函数
  11. 在他机上还原DB2的备份
  12. Python logging 模块学习
  13. 手动增加pe节并修改oep
  14. 【oneday_onepage】——Microsoft addresses DevOps with InRelease technology
  15. Struts2+Hibernate+Spring(SSH)三大框架整合jar包
  16. HDU 6343 - Problem L. Graph Theory Homework - [(伪装成图论题的)简单数学题]
  17. Java数据结构和算法(一)概念
  18. Codeforces 1118 F2. Tree Cutting (Hard Version) 优先队列+树形dp
  19. Java学习笔记XML(3)
  20. Python【每日一问】17

热门文章

  1. 【Python】【demo实验3】【显示素数,显示两个数范围内的所有素数】
  2. Python中的 _init__和 _new__的区别
  3. java this的作用
  4. 2018.08.15【2018提高组】模拟A组 比赛总结
  5. EM 算法(三)-GMM
  6. 关于__name__==&#39;__main__&#39;的理解
  7. 最长上升子序列(Longest increasing subsequence)
  8. 第二篇 jQuery 选择器
  9. vue项目中使用mockjs+axios模拟后台数据返回
  10. mock.js 模拟数据