# 暴力遍历-BZOJ-1622- [Usaco2008 Open]Word Power 名字的能量

Description

“sI”“EE”以及“Es”等等字符串，但不蕴含“lS”或“eB”．请帮约翰计算他的奶牛的名字的能量．
Input

Output

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”.

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int n,m;
const int fix='A'-'a';
char name[1005][1005],str[105][35];
int main()
{
cin >> n >> m;
for(int i=0;i<n;i++)
cin >> name[i];
for(int j=0;j<m;j++)
cin >> str[j];
for(int i=0;i<n;i++)
{
for(int j=0;j<strlen(name[i]);j++)
if(name[i][j]>'Z')
name[i][j]+=fix;
}
for(int i=0;i<m;i++)
{
for(int j=0;j<strlen(str[i]);j++)
if(str[i][j]>'Z')
str[i][j]+=fix;
}
for(int i=0;i<n;i++)
{
int out=0,l=strlen(name[i]);
for(int j=0;j<m;j++)
{
int now=0,left=strlen(str[j]);
for(int z=0;z<strlen(str[j]);z++)
{
while(now<l && name[i][now]!=str[j][z])
now++;
if(name[i][now]==str[j][z])
{
left--;
now++;
}
}
if(left==0)
out++;
}
cout << out << endl;
}
return 0;
}


08-18 1754
05-17 787
01-24 1013
09-11 927
10-10 572
09-09 723
04-02 699