Problem B: Excuses, Excuses!
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!的更多相关文章
- UVa 409 Excuses, Excuses!
哈哈,虽然是一道字符串水题,可是拿到一个1A还是很开心的! 题意就是给一些keywords(子串)和Excuse(母串),然后输出包含keywords最多的Excuse,如果相等的话,按任意顺序全部输 ...
- 【HDOJ】1606 Excuses, Excuses!
简单字符串. #include <cstdio> #include <cstring> #define MAXLEN 105 #define MAXN 25 char keys ...
- UVa409_Excuses, Excuses!(小白书字符串专题)
解题报告 题意: 找包括单词最多的串.有多个按顺序输出 思路: 字典树爆. #include <cstdio> #include <cstring> #include < ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 1(String)
第一题:401 - Palindromes UVA : http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- 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 ...
随机推荐
- 转:onkeypress、onkeydown、onkeyup 区别
在使用JavaScript做WEB键盘事件侦听捕获时,主要采用onkeypress.onkeydown.onkeyup三个事件进行出来.该三个事件的执行顺序如下:onkeydown -> onk ...
- Linux中搭建SVN服务器
一 下载工具 1. subversion-1.6.17.tar.gz 2. subversion-deps-1.6.17.tar.gz 二 解压两个包: 1.在此之前,我已经创建了一个用户svnroo ...
- ReactNative实现通知监听事件
事例1: 只在rn里面发送和接受消息. A界面: import {DeviceEventEmitter} from 'react-native'; //... componentDidMount(){ ...
- iOS 开发 UI 搭建心得(一)—— 驾驭 StoryBoard
本系列文章中,我们将一起认识.了解当下 iOS 开发中几种常见的 UI 构建方式,分析他们分别适合的使用场景,以便让我们在以后的开发中,能够在恰当的时间.场景下做出最佳的选择,提升开发效率,增强程序的 ...
- asp.net验证码及怎么获取里面的数值(整合)
一.ASP.Net的验证码的作用 对于一个预防攻击的web表单来讲,验证码通常是一个常见的措施.因为如果对于一些public区域的页面内容来讲,譬如一个登录表单,如果没有必要的安全措施,很可能遭到模拟 ...
- ios不同版本下的UILabel自动换行问题
@interface ThreadPreviewCell : UITableViewCell @property (nonatomic, strong) UILabel *titleLabel; @e ...
- VS2010断点无效
可能的原因如下: 1. 菜单tools->Options->Debugging->General,有个Require source files to exactly match t ...
- 在View中使用CGridCtrl时出现系统异常
一.简介 我的程序是单文档程序,我的View视图需要使用CGridCtrl,于是我把CGridCtrl作为子窗口嵌入到View中覆盖住整个View.由于不能像gridctrl_demo227那样直接在 ...
- A - A
A - A Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status ...
- Android Studio 解决方法No JVM installation found. Please install a 64-bit JDK.
————————— Error launching Android Studio ————————— No JVM installation found. Please install a 64-bi ...