http://www.lydsy.com/JudgeOnline/problem.php?id=1622

Description

    约翰想要计算他那N(1≤N≤1000)只奶牛的名字的能量.每只奶牛的名字由不超过1000个字待构成,没有一个名字是空字体串,  约翰有一张“能量字符串表”,上面有M(1≤M≤100)个代表能量的字符串.每个字符串由不超过30个字体构成,同样不存在空字符串.一个奶牛的名字蕴含多少个能量字符串,这个名字就有多少能量.所谓“蕴含”,是指某个能量字符串的所有字符都在名字串中按顺序出现(不一定一个紧接着一个).
    所有的大写字母和小写字母都是等价的.比如,在贝茜的名字“Bessie”里,蕴含有“Be”
“sI”“EE”以及“Es”等等字符串,但不蕴含“lS”或“eB”.请帮约翰计算他的奶牛的名字的能量.

Input

    第1行输入两个整数N和M,之后N行每行输入一个奶牛的名字,之后M行每行输入一个能量字符串.

Output

 
    一共N行,每行一个整数,依次表示一个名字的能量.

Sample Input

5 3
Bessie
Jonathan
Montgomery
Alicia
Angola
se
nGo
Ont

INPUT DETAILS:

There are 5 cows, and their names are "Bessie", "Jonathan",
"Montgomery", "Alicia", and "Angola". The 3 good strings are "se",
"nGo", and "Ont".

Sample Output

1
1
2
0
1

OUTPUT DETAILS:

"Bessie" contains "se", "Jonathan" contains "Ont", "Montgomery" contains
both "nGo" and "Ont", Alicia contains none of the good strings, and
"Angola" contains "nGo".

HINT

 

Source

Silver

 #include <cstring>
#include <cstdio> const int N();
char name[N][N];
int n,m,ans[N]; inline void Get(char *s)
{
int len=strlen(s);
for(int i=; i<n; ++i)
{
int k=,L=strlen(name[i]);
for(int j=; j<L; ++j)
{
if((name[i][j]-s[k]==)||name[i][j]==s[k]||
(s[k]-name[i][j]==)) k++;
if(k==len) { ans[i]++; break; }
}
}
} int Presist()
{
scanf("%d%d",&n,&m);
for(int i=; i<n; ++i)
scanf("%s",name[i]);
for(char s[N]; m--; )
scanf("%s",s),Get(s);
for(int i=; i<n; ++i)
printf("%d\n",ans[i]);
return ;
} int Aptal=Presist();
int main(int argc,char**argv){;}

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 名字的能量【模拟】

    模拟即可,注意包含可以是不连续的 方便起见读入的时候全转成小写 #include<iostream> #include<cstdio> using namespace std; ...

  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. Linux 用户管理切换用户su和提取命令sudo-visudu详解

    一.su --run a shell with substitute user and group IDs -,-l,--login make the shell a login shell, cle ...

  2. Python基础——字典(dict)

    由键-值对构建的集合. 创建 dic1={} type(dic1) dic2=dict() type(dic2) 初始化 dic2={'hello':123,'world':456,'python': ...

  3. python-函数的对象、函数嵌套、名称空间和作用域

    目录 函数的对象 函数对象的四大功能 引用 当做参数传给一个函数 可以当做函数的返回值 可以当做容器类型的元素 函数的嵌套 函数的嵌套定义 函数的嵌套调用 名称空间与作用域 名称空间 内置名称空间 全 ...

  4. 使用TensorFlow的卷积神经网络识别手写数字(3)-识别篇

    from PIL import Image import numpy as np import tensorflow as tf import time bShowAccuracy = True # ...

  5. python3通过Beautif和XPath分别爬取“小猪短租-北京”租房信息,并对比时间效率(附源代码)

    爬虫思路分析: 1. 观察小猪短租(北京)的网页 首页:http://www.xiaozhu.com/?utm_source=baidu&utm_medium=cpc&utm_term ...

  6. SQL_2_查询Select语句的使用

    查询一词在SQL中并不是很恰当,在SQL中查询除了向数据库提出问题之外,还可以实现下面的功能: 1>建立或删除一个表 2>插入.修改.或删除一个行或列 3>用一个特定的命令从几个表中 ...

  7. holtek编程注意事项

    1.holtek单片机中断服务函数中函数调用里的参数不能传递地址,不然程序就会跑飞 2.holtek单片机尽量不要函数嵌套很多层,嵌套过多,会导致单片机复位

  8. UVa 465 Overflow——WA

    上次那个大数开方的高精度的题,UVa113 Power of Cryptography,直接两个double变量,然后pow(x, 1 / n)就A过去了. 怎么感觉UVa上高精度的题测试数据不给力啊 ...

  9. Html开发小结

    html部分 1.html标签 标签不区分大小写. 如:<!doctype html>与<!DOCTYPE html > <div></div>与< ...

  10. Selenium WebDriver- 指定页面加载时间

    #encoding=utf-8 import unittest import time from selenium import webdriver from selenium.webdriver i ...