[BZOJ1622] [Usaco2008 Open]Word Power 名字的能量
来源:互联网 发布:2017淘宝销量排行榜 编辑:程序博客网 时间:2024/05/16 11:46
[Usaco2008 Open]Word Power 名字的能量
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”.
Source
Silver
var x:array[0..1000]of ansistring; ans:array[0..1000]of longint; y:array[0..100]of ansistring; i,j,k,l,len:longint; n,m:longint; t:ansistring;begin readln(n,m); for i:=1 to n do begin t:=''; readln(x[i]); for j:=1 to length(x[i]) do if ord(x[i][j])<=90 then t:=t+chr(ord(x[i][j])+32) else t:=t+x[i][j]; x[i]:=t; end; for i:=1 to m do begin t:=''; readln(y[i]); for j:=1 to length(y[i]) do if ord(y[i][j])<=90 then t:=t+chr(ord(y[i][j])+32) else t:=t+y[i][j]; y[i]:=t; end; for i:=1 to n do begin for j:=1 to m do begin len:=1; for k:=1 to length(x[i]) do begin if x[i][k]=y[j][len] then begin inc(len); if len=length(y[j])+1 then begin inc(ans[i]); break; end; end; end; end; end; for i:=1 to n do writeln(ans[i]);end.
- bzoj1622 [Usaco2008 Open]Word Power 名字的能量
- [BZOJ1622] [Usaco2008 Open]Word Power 名字的能量
- bzoj1622【Usaco2008 Open】Word Power 名字的力量
- BZOJ 1622: [Usaco2008 Open]Word Power 名字的能量
- BZOJ 1622: [Usaco2008 Open]Word Power 名字的能量
- BZOJ 1622: [Usaco2008 Open]Word Power 名字的能量
- bzoj 1622: [Usaco2008 Open]Word Power 名字的能量
- 暴力遍历-BZOJ-1622- [Usaco2008 Open]Word Power 名字的能量
- [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
- BZOJ 1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
- BZOJ 1604 [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 Treap
- bzoj1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
- 【bzoj1604】: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
- [BZOJ1604] [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
- bzoj 1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
- BZOJ 1604 [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
- 【bzoj1604】【[Usaco2008 Open]Cow Neighborhoods】简单的谈谈曼哈顿距离
- Power Word
- leetcode 53: Spiral Matrix
- 《C++编程思想》第六章 输入输出流介绍(原书代码+习题+解答)
- POJ 1573 Robot Motion
- mysql远程无法登陆解决办法
- Invert Binary Tree
- [BZOJ1622] [Usaco2008 Open]Word Power 名字的能量
- HDU-1896-Stones
- 项目笔记用到的链接
- LeetCode题解——Swap Nodes in Pairs
- chrome 支付宝控件安装
- getopt()
- 数据结构和算法学习笔记-1
- 蚂蚁的难题(三)
- HDU 5317 RGCDQ