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 (  ) defines the number of keywords to be used in the
    search. The second number (  ) 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 (  ) 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!
还是串处理。。
题意:给一个字典,然后给e行串 问哪行串里面的出现的单词次数最多,有多个则输出多个
思路:字典扔set里。。然后gets成行读进来转换成单词哎个查询。。然后就完了。。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cctype>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define ll long long
#define maxn 360
#define pp pair<int,int>
#define INF 0x3f3f3f3f
#define max(x,y) ( ((x) > (y)) ? (x) : (y) )
#define min(x,y) ( ((x) > (y)) ? (y) : (x) )
using namespace std;
char tem[88],exc[22][77];
int k,e,p,ans[22];
int main()
{
int cas=1;
while(~scanf("%d%d",&k,&e))
{
getchar();
memset(ans,0,sizeof(ans));
string x;set <string> s;
while(k--)
{
cin>>x;
s.insert(x);
}
getchar();
for(int i=0;i<e;i++)
{
gets(exc[i]);
int len=strlen(exc[i]);
for(int j=0;j<=len;)
if(isalpha(exc[i][j]))
{
p=0;tem[p++]=tolower(exc[i][j]);j++;
while(isalpha(exc[i][j]))
tem[p++]=tolower(exc[i][j++]);
tem[p++]='\0';string y(tem);
if(s.count(y))
ans[i]++;
}
else
j++;
}
printf("Excuse Set #%d\n",cas++);
int Max=-INF;
for(int i=0;i<e;i++)
Max=max(Max,ans[i]);
for(int i=0;i<e;i++)
if(ans[i]==Max)
printf("%s\n",exc[i]);
puts("");
}
return 0;
}

Uva 409-Excuses, Excuses!(串)的更多相关文章

  1. UVa 409 Excuses, Excuses!

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

  2. Problem B: Excuses, Excuses!

    Description Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame ex ...

  3. UVa 129 困难的串

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. UVA 129困难的串【DFS】

    题目链接 题目大意: 给出n,l:要求按特定格式输出由前l个大写字母构成的按字母表排列的第n个没有连续重复子串的字符串以及该字符串长度. 此题是一道dfs递归回溯的基础题,难点在于对当前字符串是否有连 ...

  5. 【HDOJ】1606 Excuses, Excuses!

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

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

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

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

  8. UVA题目分类

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

  9. Volume 1. String(uva)

    10361 - Automatic Poetry #include <iostream> #include <string> #include <cstdio> # ...

随机推荐

  1. 推断序列的端部的大小C规划

    概念 big-endian格式:高字节字符数据被存储在低地址.字数据的低字节存放在高地址. 小尾数格式:相较于大端存储格式,在小尾数格式.低地址存储在字数据的低字节.的是字数据的高字节. 如5A6C中 ...

  2. 追索权 Eclipse + NDK error: stray &#39;\24&#39; in program

    [size=16px][b][color=#FF0000]追索权 Eclipse + NDK  error: stray '\24' in program[/color][b][/b][/b][/si ...

  3. crm2011i创建nt类型字段

    using System;     using Microsoft.Xrm.Sdk;     using Microsoft.Xrm.Sdk.Messages;     using Microsoft ...

  4. Java彻底 - WEB容器的侦听具体解释 ServletContextListener

    WEB容器的侦听器ServletContextListener主要用于监测容器启动和 当破坏需要做一些操作,听众将能够使用此做. ServletContextListener在Spring开始,然后再 ...

  5. SQL -- 是否或推断线相交以在其内部的平面

    SQL如下面: update mapping_nj_roads set municipality='227' from mapping_geodata_boundary a where a.suppo ...

  6. HDFS Safemode问题

    处于safemode的集群是无法接收不论什么写操作的,包含创建文件夹.删除文件.改动文件.上传文件等等. 关于safemode,在http://www.iteblog.com/archives/977 ...

  7. 终端查询数据库sqlite(创建你自己,或者是coredata创建)那里的东西

    首先需要知道数据库的路径,coredata一般都是在沙箱中创建Documents目录的.虽然他建立了自己看, sqlite3 #数据库路径#        //进入数据库 .tables  //查看数 ...

  8. 简单介绍如何使用PowerMock和Mockito来mock 1. 构造函数 2. 静态函数 3. 枚举实现的单例 4. 选择参数值做为函数的返回值(转)

    本文将简单介绍如何使用PowerMock和Mockito来mock1. 构造函数2. 静态函数3. 枚举实现的单例4. 选择参数值做为函数的返回值5. 在调用mock出来的方法中,改变方法参数的值 一 ...

  9. C#之关于时间的整理

    今天在整理C#的异步编程的时候,看到一个Stopwatch类.让我想起了,时候整理一下C#关于时间的类,望补充.斧正. DataTime类 表示时间上的一刻,即某个时间节点,通常以日期和当天的时间表示 ...

  10. AndroidUI的组成部分RoomButton

    <!-- 知识点汇总: 1.Button与ImageButton的差别在于,Button生成的button上显示文字 而ImageButton上则显示图片.须要指出的是:为ImageButton ...