模拟即可,注意包含可以是不连续的

方便起见读入的时候全转成小写

#include<iostream>
#include<cstdio>
using namespace std;
const int N=1005;
int n,m,s1,s2,ans[N];
struct qwe
{
int len;
char s[N];
}c[N],p[N];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%s",c[i].s);
while(c[i].s[c[i].len])
{
if(c[i].s[c[i].len]<'a')
c[i].s[c[i].len]=c[i].s[c[i].len]+32;
c[i].len++;
}
}
for(int i=1;i<=m;i++)
{
scanf("%s",p[i].s);
while(p[i].s[p[i].len])
{
if(p[i].s[p[i].len]<'a')
p[i].s[p[i].len]=p[i].s[p[i].len]+32;
p[i].len++;
}
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
s1=0,s2=0;
while(s1<c[i].len&&s2<p[j].len)
{
if(c[i].s[s1]==p[j].s[s2])
s2++;
s1++;
}
if(s2==p[j].len)
ans[i]++;
}
for(int i=1;i<=n;i++)
printf("%d\n",ans[i]);
return 0;
}

bzoj 1622: [Usaco2008 Open]Word Power 名字的能量【模拟】的更多相关文章

  1. BZOJ 1622: [Usaco2008 Open]Word Power 名字的能量

    题目 1622: [Usaco2008 Open]Word Power 名字的能量 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 349  Solved ...

  2. BZOJ——1622: [Usaco2008 Open]Word Power 名字的能量

    http://www.lydsy.com/JudgeOnline/problem.php?id=1622 Description     约翰想要计算他那N(1≤N≤1000)只奶牛的名字的能量.每只 ...

  3. 1622: [Usaco2008 Open]Word Power 名字的能量

    1622: [Usaco2008 Open]Word Power 名字的能量 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 370  Solved: 18 ...

  4. 【BZOJ】1622: [Usaco2008 Open]Word Power 名字的能量(dp/-模拟)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1622 这题我搜的题解是dp,我也觉得是dp,但是好像比模拟慢啊!!!! 1400ms不科学! 设f[ ...

  5. [Usaco2008 Open]Word Power 名字的能量

    1622: [Usaco2008 Open]Word Power 名字的能量 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 408  Solved: 19 ...

  6. bzoj1622 [Usaco2008 Open]Word Power 名字的能量

    Description     约翰想要计算他那N(1≤N≤1000)只奶牛的名字的能量.每只奶牛的名字由不超过1000个字待构成,没有一个名字是空字体串,  约翰有一张“能量字符串表”,上面有M(1 ...

  7. BZOJ_1622_[Usaco2008_Open]_Word_Power_名字的能量_(字符匹配_暴力)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1622 给出多个文本串和模式串,求每个文本串中有多少模式串. 分析 直接暴力... #inclu ...

  8. 洛谷——P2908 [USACO08OPEN]文字的力量Word Power

    P2908 [USACO08OPEN]文字的力量Word Power 题目描述 Farmer John wants to evaluate the quality of the names of hi ...

  9. 洛谷 P2908 [USACO08OPEN]文字的力量Word Power

    P2908 [USACO08OPEN]文字的力量Word Power 题目描述 Farmer John wants to evaluate the quality of the names of hi ...

随机推荐

  1. POJ-20407Relatives/NYOJ-333mdd的烦恼,欧拉函数简单应用,模板A

     poj                         Relatives                                Time Limit: 1000MS   Memory Li ...

  2. [luoguP3402] 最长公共子序列(DP + 离散化 + 树状数组)

    传送门 比 P1439 排列LCS问题,难那么一点点,只不过有的元素不是两个串都有,还有数据范围变大,树状数组得打离散化. 不过如果用栈+二分的话还是一样的. ——代码 #include <cs ...

  3. android studio配置so文件路径

    将一个项目从eclipse上移植到android studio时,发现总是加载不成功库文件,so库文件放在了main/src/libs下的目录. 参考网上资料,studio默认的库文件路径是main/ ...

  4. [NOIP2006] 普及组

    明明的随机数 STL真是偷懒神器 /*by SilverN*/ #include<algorithm> #include<iostream> #include<cstri ...

  5. Jquery为DIV添加点击事件,Jquery为a标签超链接添加点击事件

    <div>1</div> <div>2</div> <div>3</div> <div>4</div> ...

  6. python类变量以及应用场景

    类变量是python 中class 的变量,区别于实例的变量.我们通过一些例子具体了解一下 先看下面的例子 >>> class Demo(object): ... v1 = 1 .. ...

  7. neutron trouble shooting - ip can not ping

    neutron创建了一个router后,显示列表如下: [root@controller01 keystone]# neutron router-port-list router +--------- ...

  8. 004 ospf

    r0(config)#router ospf 1 OSPF process 1 cannot start. There must be at least one "up" IP i ...

  9. [React] Use Prop Collections with Render Props

    Sometimes you have common use cases that require common props to be applied to certain elements. You ...

  10. [Jest] Automate your migration to Jest using codemods

    Jest is a fantastic testing library, but maybe you've been putting off the switch because migrating ...