Description

Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame excuses in order to avoid serving. In order to reduce the amount of time required listening to goofy excuses, Judge Ito has asked that you write
a program that will search for a list of keywords in a list of excuses identifying lame excuses. Keywords can be matched in an excuse regardless of case.

Input

Input to your program will consist of multiple sets of data.

Line 1 of each set will contain exactly two integers. The first number ( tex2html_wrap_inline30 ) defines the number of keywords to be used in the search. The second number ( tex2html_wrap_inline32 ) defines the number of excuses
in the set to be searched.

Lines 2 through K+1 each contain exactly one keyword.

Lines K+2 through K+1+E each contain exactly one excuse.

All keywords in the keyword list will contain only contiguous lower case alphabetic characters of length L ( tex2html_wrap_inline42 ) and will occupy columns 1 through L in the input line.

All excuses can contain any upper or lower case alphanumeric character, a space, or any of the following punctuation marks [SPMamp".,!?&] not including the square brackets and will not exceed 70 characters in length.

Excuses will contain at least 1 non-space character.

Output

For each input set, you are to print the worst excuse(s) from the list.

The worst excuse(s) is/are defined as the excuse(s) which contains the largest number of incidences of keywords.

If a keyword occurs more than once in an excuse, each occurrance is considered a separate incidence.

A keyword ``occurs" in an excuse if and only if it exists in the string in contiguous form and is delimited by the beginning or end of the line or any non-alphabetic character or a space.

For each set of input, you are to print a single line with the number of the set immediately after the string ``Excuse Set #". (See the Sample Output). The following line(s) is/are to contain the worst excuse(s) one per line exactly as read in. If there is
more than one worst excuse, you may print them in any order.

After each set of output, you should print a blank line.

Sample Input

5 3
dog
ate
homework
canary
died
My dog ate my homework.
Can you believe my dog died after eating my canary... AND MY HOMEWORK?
This excuse is so good that it contain 0 keywords.
6 5
superhighway
crazy
thermonuclear
bedroom
war
building
I am having a superhighway built in my bedroom.
I am actually crazy.
1234567890.....,,,,,0987654321?????!!!!!!
There was a thermonuclear war!
I ate my dog, my canary, and my homework ... note outdated keywords?

Sample Output

Excuse Set #1
Can you believe my dog died after eating my canary... AND MY HOMEWORK? Excuse Set #2
I am having a superhighway built in my bedroom.
There was a thermonuclear war!
#include<stdio.h>
#include<string.h>
int main()
{
int m,n,i,j,t,k,w=0;
char a[100][100],b[100][100],c[100][100],x[100];
int y;
while(scanf("%d%d",&m,&n)!=EOF)
{
int num[100]={0};
w++;
getchar();
for(i=0;i<m;i++)
{
gets(a[i]);
for(j=0;a[i][j];j++)
{
if(a[i][j]>='A'&&a[i][j]<='Z')
a[i][j]=a[i][j]+32;
}
}
for(i=0;i<n;i++)
{
gets(b[i]);
for(j=0;b[i][j];j++)
{
c[i][j]=b[i][j];
if(c[i][j]>='A'&&c[i][j]<='Z')
c[i][j]=c[i][j]+32;
}
c[i][j]='\0';
y=0;
for(j=0;c[i][j];j++)
{
if(c[i][j]>='a'&&c[i][j]<='z')
{
x[y++]=c[i][j];
}
else
{
x[y]='\0';
for(k=0;k<m;k++)
{
if(strcmp(x,a[k])==0)
{
num[i]++;
break;
}
}
y=0;
}
}
// for(i=0;i<n;i++)
// printf("%d\n",num[i]);
}
int max=0;
printf("Excuse Set #%d\n",w);
for(i=0;i<n;i++)
{
if(num[i]>=max)
max=num[i];
}
for(i=0;i<n;i++)
{
if(max==num[i])
{
printf("%s\n",b[i]);
}
}
printf("\n");
}
return 0;
}

Problem B: Excuses, Excuses!的更多相关文章

  1. UVa 409 Excuses, Excuses!

    哈哈,虽然是一道字符串水题,可是拿到一个1A还是很开心的! 题意就是给一些keywords(子串)和Excuse(母串),然后输出包含keywords最多的Excuse,如果相等的话,按任意顺序全部输 ...

  2. 【HDOJ】1606 Excuses, Excuses!

    简单字符串. #include <cstdio> #include <cstring> #define MAXLEN 105 #define MAXN 25 char keys ...

  3. UVa409_Excuses, Excuses!(小白书字符串专题)

    解题报告 题意: 找包括单词最多的串.有多个按顺序输出 思路: 字典树爆. #include <cstdio> #include <cstring> #include < ...

  4. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  5. 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 1(String)

    第一题:401 - Palindromes UVA : http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8 ...

  6. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  7. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  8. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  9. UVA大模拟代码(白书训练计划1)UVA 401,10010,10361,537,409,10878,10815,644,10115,424,10106,465,10494

    白书一:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=64609#overview 注意UVA没有PE之类的,如果PE了显示WA. UVA ...

随机推荐

  1. ProcessBuilder 和 Runtime(转)

    ProcessBuilder.start() 和 Runtime.exec() 方法都被用来创建一个操作系统进程(执行命令行操作),并返回 Process 子类的一个实例,该实例可用来控制进程状态并获 ...

  2. POJ 3692 Kindergarten (二分图 最大团)

    Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5660   Accepted: 2756 Desc ...

  3. Cocos2d-x 3.1.1 学习日志6--30分钟了解C++11新特性

    新的keyword auto C++11中引入auto第一种作用是为了自己主动类型推导 auto的自己主动类型推导,用于从初始化表达式中判断出变量的数据类型.通过auto的自己主动类型推导.能够大大简 ...

  4. js 取消listbox选中的项

    <input type="button" id="cel" value="取消选择" onclick="clearListB ...

  5. web - 清除浮动

    最理想的方式为 伪类 + content : 例如 div:after{content:"";display:block;clear:both;} div{zoom:1;} 另外, ...

  6. Deep Learning(深度学习)学习笔记整理系列之(四)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  7. sql中复合组建解析

    每个表只能有一个主键 唯一键/约束可以多个 复合主键是指复合唯一,比如: 1 1 1 2 2 1 2 2 单看任何一列都不是唯一,但组合起来就是唯一的. Create Table 表名 (字段名1 I ...

  8. spring mvc 简单搭建

    文中用的框架版本:spring 3,hibernate 3,没有的,自己上网下. web.xml配置: </load-on-startup>     </servlet>    ...

  9. 批量修改文件名java

    package test0715; import java.io.File; public class FileRename {public static void main(String[] arg ...

  10. 算法学习笔记(LeetCode OJ)

    ================================== LeetCode的一些算法题,都是自己做的,欢迎提出改进~~ LeetCode:http://oj.leetcode.com == ...