题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3150

Problem Description





Mystery Science Theater 3000 is about to start, which means it's time for "Robot Roll Call", where the name of each robot is called out, as per the list received from Earth. The expectation is that if a robot is there, it will respond by adding its name to
a data stream which is then sent back to Earth. Unfortunately today, once the roll is received, communication with Earth is temporarily lost. In the meantime, the robots that are present for roll call have saved their names to the data stream. However, lots
of other things are also being saved to this same stream. To help extract data later, any data placed in the stream is separated by whitespace. Once the communication problems are resolved, the contents of this stream are relayed to Earth.



Your task is as follows. Given a list of names for roll call, you must scan the accompanying data stream and determine if a given name is there. For each name that is in the roll call, report whether or not that name was in the data stream. For a name to be
a match, it must appear EXACTLY as shown in the roll. This means a match is case-sensitive and sub-string matches are not allowed.
 
Input
The first entry in the file will be an integer value t (t > 0) that represents the number of test data sets the file contains. Following this entry, will be t test sets. Each test set will start with an integer n (0
n < 26) representing the number of names in the roll. On the lines that follow will be n entries, one per line, containing the individual names in the roll. No name will have more than 25 characters. Names will only contain
the characters A-Z, a-z, and 0-9. Names will be unique.



Following the names will be an integer d (0 < d < 100) representing the number of lines in the data stream. On each subsequent line will be the characters that make up the data stream. Each line of the data stream will contain
at least one character and at most 100. Furthermore, the data on a given line will be separated by whitespace (space, tab, or combination of the two). Finally, any names from the roll that might occur as part of the data stream will be found on one line (a
name will not be split across lines).
 
Output
Write the test set number (starting at 1) on a line of its own, followed by the names in the roll and whether or not a given name was found in the data stream. Each of these names should occur on a line of their own. Add a blank line to the end of each test
case. Output format must be identical to the sample output shown below.
 
Sample Input
2
4
Gypsy
TomServo
CrowTRobot
Cambot
2
Manos Torgo Joel 101010 Gypsy tomservo
Fugitive Alien Time of the Apes crowTrobot Cambot
2
R2D2
C3PO
1
Boba Fett c3Po R2D22 Jar Jar Binks Luke give in to the dark side
 
Sample Output
Test set 1:
Gypsy is present
TomServo is absent
CrowTRobot is absent
Cambot is present
Test set 2:
R2D2 is absent
C3PO is absent
 
Source

PS:

推断给出的表单是否在以下有出现!

代码例如以下:

#include <cstdio>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
map<string,int>mm;
int main()
{
string name[117];
int t;
int n;
int cas = 0;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
mm.clear();
for(int i = 0; i < n; i++)
{
cin>>name[i];
}
int m;
scanf("%d",&m);
char s[1000];
string ss="";
for(int i = 0; i < m; i++)
{ getchar();
gets(s);
for(int j = 0; j < strlen(s); j++)
{
if(s[j]==' ')
{
mm[ss]++;
ss="";
continue;
}
ss+=s[j];
}
mm[ss]++;
ss="";
}
printf("Test set %d:\n",++cas);
for(int i = 0 ; i < n; i++)
{
if(mm[name[i]])
{
//printf("%s is present\n",name[i]);
cout<<name[i]<<" is present"<<endl;
}
else
{
//printf("%s is absent\n",name[i]);
cout<<name[i]<<" is absent"<<endl;
}
}
printf("\n");
}
return 0;
}

HDU 3150 Robot Roll Call – Cambot…Servo…Gypsy…Croooow(map)的更多相关文章

  1. HDU 4504 威威猫系列故事——篮球梦(dp)

    http://acm.hdu.edu.cn/showproblem.php?pid=4504 题目大意: 中文都看得懂.不过我是看hint才正确理解什么意思的.开始的时候理解错了. 解题思路: 给定时 ...

  2. robot framework学习笔记之一 资源文件(Resource)和外部资源(External Resources)

    一.资源文件(Resource) 测试套件主要是存放测试案例,资源文件主要是用来存放用户关键字. 添加资源    在目录型的Project/Test Suite下单击鼠标右键,选择『New Resou ...

  3. hdu 1800 (map)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/ ...

  4. HDU 5716 带可选字符的多字符串匹配(ShiftAnd)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5716 [题目大意] 给出一个字符串,找出其中所有的符合特定模式的子串位置,符合特定模式是指,该子串 ...

  5. HDU 5095 Linearization of the kernel functions in SVM(模拟)

    主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5095 Problem Description SVM(Support Vector Machine) ...

  6. hdu Word Amalgamation(map)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 找单词 #include <iostream> #include <strin ...

  7. hdu What Are You Talking About(map)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 map简单应用 代码: #include <stdio.h> #include &l ...

  8. HDU 1263:水果(map)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 #include <stdio.h> #include <string.h&g ...

  9. 【hdu 2112】 HDU Today ( 最短路 Dijkstra)(map)

    http://acm.hdu.edu.cn/showproblem.php?pid=2112 这道题给了一个将字符串与int对应的思路,就是使用map 这道题答案对了,但是没有AC,我也不知道为什么. ...

随机推荐

  1. Python+Selenium练习篇之18-获取元素上面的文字

    本文介绍如何通过Selenium方法来获取某一个元素的text属性值.在很多自动化测试脚本中,需要多次获取元素的text值,拿过来进行对比和匹配.例如,在一个登陆界面,如果不输入用户名和密码,直接点击 ...

  2. URL 传参中需要处理的特殊字符

    例如实际请求URL如下: http://www.douwansha.com/mdeditor?data=[{"address":null,"name":&quo ...

  3. dijkstra 堆优化

    #include <iostream> #include <vector> #include <cstring> #include <queue> us ...

  4. 菜鸟之路——机器学习之线性回归个人理解及Python实现

    这一节很简单,都是高中讲过的东西 简单线性回归:y=b0+b1x+ε.b1=(Σ(xi-x–)(yi-y–))/Σ(xi-x–)ˆ2       b0=y--b1x-    其中ε取 为均值为0的正态 ...

  5. 导入50G文件到mysql,然后再倒入sqlserver

    --导入大文件50G文件到mysql1.修改配置innodb_flush_log_at_trx_commit=0 2.导入时的注意事项set autocommit=1;show variables l ...

  6. c++ 运算符重载operator

    一般格式为: 函数类型 operator 运算符名称(形参列表){ 对运算符的重载 } 注意函数名是由operator和运算符组成.在上面的一般格式中,operator是关键字,是专门用于重载运算符函 ...

  7. 微信小程序--问题汇总及详解之图片上传和地图

    地图用的是百度的地图,链接:http://lbsyun.baidu.com/index.php?title=wxjsapi/guide/getlocation 获取日期时间可以用小程序里自带的js文件 ...

  8. MySql数据库 - 5.用C#连接数据库

    添加 dll 引用,dll 位置:C:\Program Files (x86)\MySQL\Connector NET 8.0\Assemblies\v4.5.2 引入命名空间:MySql.Data. ...

  9. BZOJ3997 [TJOI2015]组合数学 【Dilworth定理】

    题目 给出一个网格图,其中某些格子有财宝,每次从左上角出发,只能向下或右走.问至少走多少次才能将财宝捡完.此对此问题变形,假设每个格子中有好多财宝,而每一次经过一个格子至多只能捡走一块财宝,至少走多少 ...

  10. P2647 最大收益 (动态规划)

    题目链接 Solution 乍一看发现正着 DP,有明显的后效性,所以就反过来做. 但是同时发现很显然减去多的放后面明显更优,所以按 \(R\) 从大排序. 然后 \(f[i][j]\) 代表前 \( ...