HNAU 16th Training Problem 第16次训练 2013 /09 /25 AMA.模拟 poj 1677 B.博弈 poj 2234 经典博弈算法 C.数学 poj 1244 Slots of Fun D.动态规划 poj 2184(活用dp) E.贪心 poj 1716 F.dp poj 1649 G.网络流 poj 1325 machine schedule H.搜索 poj 2339 |
#include <iostream>
#include <cstdio>#include <cstring>
#include <string>
#include <map>
#include <set>
using namespace std;
string s[5];
int g,len;
bool rang(string str)
{
bool f=0;
for(int i=0;i<g;i++)
if(str.find(s[i],0)<len)
{
if(f)printf(" ");
f=1;
printf("%s",s[i].c_str());
}
return f;
}
int cnt(string str)
{
int i;
int a=0;
char bef=str[0];
for(i=1;i<len-1;i++)
if(bef!=' '&&bef!='!'&&(str[i]==' '||str[i]=='!'))
{ a++;
bef=str[i];
}
return a;
}
void comment(string str)
{
if(cnt(str)<=8)
printf(": oh\n");
else
{
if(str.find("beautiful",0)<len||str.find("pretty",0)<len||str.find("lovely",0)<len)
printf(": xixi\n");
else
printf(": hehe\n");
}
}
void deal(char str[])
{
for(int i=0;i<len;i++)
if(str[i]>='A'&&str[i]<='Z')
str[i]=str[i]+32;
}
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
char str[502];
int m,i;
scanf("%d%d",&g,&m);
{
getchar();
for(i=0;i<g;i++)
{
gets(str);
s[i]=str;
}
for(i=0;i<m;i++)
{
gets(str);
len=strlen(str);
deal(str);
if(!rang(str))
{
printf("All");
}
comment(str);
}
}
return 0;
}