HDU 3150 Robot Roll Call – Cambot…Servo…Gypsy…Croooow(map)

题目链接: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

2008 ACM-ICPC Pacific Northwest Region

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;
}
时间: 2024-08-24 09:05:04

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

HDU 4513 吉哥系列故事——完美队形II(Manacher)

Problem Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要求,则就是新的完美队形: 1.挑出的人保持原队形的相对顺序不变,且必须都是在原队形中连续的: 2.左右对称,假设有m个人形成新的队形,则第1个人和第m个人身高相同,第2个人和第m-1个人身高相同,依此类推,当然如果m是奇数,中间那个人可以任意: 3.从左到中间那

HDU 4081 Qin Shi Huang&#39;s National Road System(prim)

Qin Shi Huang's National Road System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5153    Accepted Submission(s): 1795 Problem Description During the Warring States Period of ancient China(4

hdu 1800 (map)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10830    Accepted Submission(s): 3472 Problem Description In the year 8888, t

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

http://acm.hdu.edu.cn/showproblem.php?pid=4504 题目大意: 中文都看得懂.不过我是看hint才正确理解什么意思的.开始的时候理解错了. 解题思路: 给定时间最多是600,最多进攻次数600/15=40次,我方进攻次数40/2=20次.如果深度搜索多少种情况, 那么时间复杂度是O(3^20),直接就超时了. 我知道要动态规划,但是自己dp不行,所以就看了网上别人的解题报告. dp[i][j]=dp[i-1][j-1]+dp[i-1][j-2]+dp[i

HDU 1025 Constructing Roads In JGShining&amp;#39;s Kingdom (DP)

Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of these cities are rich in resource (we call them rich cities) while the others are short of resource (we ca

Robot Framework自动化测试第一个用例(二)

RIDE启动界面: 首先创建一个Test project File-New Project ,选择Directory类型 在创建的文件夹上右键,创建一个Test Suite Openbaidu, NEW SUITE,选择ROBOT类型 接下来添加一个Test case到上述Test Suite 点击测试套,在右侧添加Library,如果没有添加Selenium2Library将无法使用其内置封装的关键字 注意大小写敏感 黑色为导入成功,导入的库显示为红色,表示导入的库不存在.参考库不存在排查方法

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

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5095 Problem Description SVM(Support Vector Machine)is an important classification tool, which has a wide range of applications in cluster analysis, community division and so on. SVM The kernel functions

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

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5716 [题目大意] 给出一个字符串,找出其中所有的符合特定模式的子串位置,符合特定模式是指,该子串的长度为n,并且第i个字符需要在给定的字符集合Si中 [题解] 这种串与字符集的匹配称为柔性字符串匹配,采用ShiftAnd的匹配方法. bt[i]表示字符i允许在哪些位置上出现,我们将匹配成功的位置保存在dp中,那么就可以用dp[i]=dp[i-1]<<1&bt[s[i]]来更新答案了

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

http://acm.hdu.edu.cn/showproblem.php?pid=2112 这道题给了一个将字符串与int对应的思路,就是使用map 这道题答案对了,但是没有AC,我也不知道为什么.. 1 #include <iostream> 2 #include <cstdio> 3 #include <string> 4 #include <queue> 5 #include <vector> 6 #include <map>