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

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

#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. typeof instanceof操作符的相关知识

    数据类型 ECMAScript中有5中基本数据类型:Undefined Null Boolean Number String. Typeof运算符 对一个值使用typeof操作符可能返回下列某个字符串 ...

  2. CentOS下LVS DR模式负载均衡配置详解

    一安装LVS准备: 1.准备4台Centos 6.2 x86_64 注:本实验关闭 SELinux和IPtables防火墙. 管理IP地址 角色 备注 192.168.1.101 LVS主调度器(Ma ...

  3. Network(poj 3694)

    题意:一个无向图可以有重边,下面q个操作,每次在两个点间连接一条有向边,每次连接后整个无向图还剩下多少桥(注意是要考虑之前连了的边,每次回答是在上一次的基础之上) /* tarjan+LCA 先用ta ...

  4. hdu_1398_Square Coins_201404260953

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  5. 从零开始写STL—容器—vector

    从0开始写STL-容器-vector vector又称为动态数组,那么动态体现在哪里?vector和一般的数组又有什么区别?vector中各个函数的实现原理是怎样的,我们怎样使用会更高效? 以上内容我 ...

  6. POJ 2101 Intervals 差分约束

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 27746   Accepted: 10687 Description You ...

  7. lines-HDU5124(区间处理 +离散化)

    Problem Description John has several lines. The lines are covered on the X axis. Let A is a point wh ...

  8. cogs——2416. [HZOI 2016]公路修建

    2416. [HZOI 2016]公路修建 ★☆   输入文件:hzoi_road.in   输出文件:hzoi_road.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述 ...

  9. hibernate详解一

    hibernate介绍 hibernate是一个开源的轻量级的框架, hibernate框架应用在javaee三层结构中的dao层框架,在dao层对数据库进行crud操作,使用hibernate框架实 ...

  10. IDUtil 永不重复的ID

    package com.xxx.common.util; import java.util.Random; /** * 各种id生成策略 * * @version 1.0 */ public clas ...