ACM-ICPC---Robot Roll Call – Cambot…Servo…Gypsy…Croooow
来源:互联网 发布:seo技术培训 陕西 编辑:程序博客网 时间:2024/06/07 05:34
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 bet 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 ben 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).
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
24GypsyTomServoCrowTRobotCambot2Manos Torgo Joel 101010 Gypsy tomservoFugitive Alien Time of the Apes crowTrobot Cambot2R2D2C3PO1Boba Fett c3Po R2D22 Jar Jar Binks Luke give in to the dark side
题意:从给出的字符串中找出存在的字符串,存在就输出present否则输出absent
Sample Output
Test set 1:Gypsy is presentTomServo is absentCrowTRobot is absentCambot is presentTest set 2:R2D2 is absentC3PO is absent#include <cstdio>#include <cstring>#include <string>#include <sstream>#include <map>#include <vector>#include <algorithm>#include <iostream>using namespace std;int main(int argc, char *argv[]){ int t,n,m,cas=1;; string str[27],str3; char str1[110]; scanf("%d",&t); while(t--) { map<string,int> map1; scanf("%d",&n); vector<string> v; for(int i=0;i<n;i++) cin>>str[i]; //cout<<str[0]<<" "<<str[1]<<endl; scanf("%d",&m); for(int i=0;i<m;i++) { getchar(); gets(str1); stringstream str2(str1); while(str2>>str3) { v.push_back(str3); map1[str3]=1; } } printf("Test set %d:\n",cas++); for(int i=0;i<n;i++) { if(map1[str[i]]) printf("%s is present\n",str[i].c_str()); else printf("%s is absent\n",str[i].c_str()); map1[str[i]]=0; } printf("\n"); } system("PAUSE"); return 0;}
0 0
- ACM-ICPC---Robot Roll Call – Cambot…Servo…Gypsy…Croooow
- HDU 3150 Robot Roll Call – Cambot…Servo…Gypsy…Croooow(map)
- soj 1702. Robot Roll Call -- Cambot...Servo...Gypsy...Croooow
- 2013ACM-ICPC杭州赛区全国邀请赛 ——Robot
- hdu4576 Robot 2013 ACM-ICPC杭州赛区全国邀请赛 1
- 浙江大学获ACM-ICPC World Finals …
- hdu 4576 robot 2013 ACM-ICPC杭州赛区全国邀请赛——题目重现-1001-robot
- 2013 ACM-ICPC 亚洲区域赛 成都现场赛E (Exhausted Robot)
- 2014 ACM/ICPC Asia Regional Xi'an Online poj5007 Post Robot
- hdu 5007 Post Robot 水题 2014 ACM/ICPC Asia Regional Xi'an Online
- UVa1600 习题6-5 巡逻机器人 (Patrol Robot,ACM/ICPC Hanoi 2006)
- HDU 5449 Robot Dog ACM/ICPC 2015 Changchun Online(数学期望+LCA)
- 习题6-5 巡逻机器人(Patrol Robot, ACM/ICPC Hanoi 2006, UVa1600)
- The 36th ACM/ICPC Asia Regional …
- The 36th ACM/ICPC Asia Regional …
- ICPC-ACM
- ACM/ICPC
- 【2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest J】【暴力模拟】Cleaner Robot 机器人行走 决策固定
- 进阶1_MVC到MVP
- NumberUtils、ArrayUtils和RandomUtils工具类用法
- webdynpro for abap 随笔1
- PHP获取两个时间之间的年和月份及间隔天数 PHP两个日期之间的所有日期
- linux文件夹打包命令
- ACM-ICPC---Robot Roll Call – Cambot…Servo…Gypsy…Croooow
- 智能搜索
- Unity开发中的坑
- eclipse中ctrl+h默认打开是Java Search,怎么设置成默认打开是File Search?
- 运行tensorflow的例子,出现Process finished with exit code 3问题
- weblogic 12c 静默安装
- js事件监听(考虑兼容性)
- 事件的捕获和冒泡机制
- Oracle创建dblink