zoukankan      html  css  js  c++  java
  • SPY

    SPY

    时间限制: 1 Sec 内存限制: 128 MB


    题目描述

    The National Intelligence Council of X Nation receives a piece of credible information that Nation Y will send spies to steal Nation X’s confidential paper. So the commander of The National Intelligence Council take measures immediately, he will investigate people who will come into NationX. At the same time, there are two List in the Commander’s hand, one is full of spies that Nation Y will send to Nation X, and the other one is full of spies that Nation X has sent to Nation Y before. There may be some overlaps of the two list. Because the spy may act two roles at the same time, which means that he may be the one that is sent from Nation X to Nation Y, we just call this type a “dual-spy”. So Nation Y may send “dual_spy” back to Nation X, and it is obvious now that it is good for Nation X, because “dual_spy” may bring back NationY’s confidential paper without worrying to be detention by NationY’s frontier So the commander decides to seize those that are sent by NationY, and let the ordinary people and the “dual_spy” in at the same time .So can you decide a list that should be caught by the Commander?
    A:the list contains that will come to the NationX’s frontier.
    B:the list contains spies that will be sent by Nation Y.
    C:the list contains spies that were sent to NationY before.

    输入

    There are several test cases.
    Each test case contains four parts, the first part contains 3 positive integers A, B, C, and A is the number which will come into the frontier. B is the number that will be sent by Nation Y, and C is the number that NationX has sent to NationY before.
    The second part contains A strings, the name list of that will come into the frontier.
    The second part contains B strings, the name list of that are sent by NationY.
    The second part contains C strings, the name list of the “dual_spy”.
    There will be a blank line after each test case.
    There won’t be any repetitive names in a single list, if repetitive names appear in two lists, they mean the same people.

    输出

    Output the list that the commander should caught (in the appearance order of the lists B).if no one should be caught, then , you should output “No enemy spy”.

    样例输入

    8 4 3
    Zhao Qian Sun Li Zhou Wu Zheng Wang
    Zhao Qian Sun Li
    Zhao Zhou Zheng
    2 2 2
    Zhao Qian
    Zhao Qian
    Zhao Qian
    Qian Sun Li

    样例输出

    Qian Sun Li
    No enemy spy

    题意概括

    每一个样例一共有四行,第一行代表下面第二行三行四行有多少个姓名,第二行有a个姓名,代表在国界上的人,第三行有b个人的姓名,代表y国派到x国的间谍信息,第四行代表之前x派到y国的间谍信息,也就是双重间谍,问需要抓住那些间谍。

    解题思路

    遍历一遍,查看y派到x国的人员是否在国界上,如果不在就不用考虑,之后再判断是不是x派到y的间谍,要是本国的间谍肯定也不需要抓住,将之后剩下的间谍输出。

    代码

        #include<stdio.h>
        #include<string.h>
        #include<math.h>
        #include<ctype.h>
        #include<algorithm>
        using namespace std;
    
        struct date {
            int a;
            char name[100];
        }dis[1000],bb[1000];
    
        int main()
        {
            int a,b,c,n,m,i,j;
            char ch[1000];
            while(~scanf("%d %d %d",&a,&b,&c)){
                memset(dis,0,sizeof(dis));
                memset(bb,0,sizeof(bb));
                for(i=0;i<a;i++){
                    scanf("%s",dis[i].name);
                    dis[i].a=0;
                }
                for(i=0;i<b;i++){
                    scanf("%s",bb[i].name);
                    for(j=0;j<a;j++){
                        if(strcmp(dis[j].name,bb[i].name)==0){
                            bb[i].a=1;
                        }
                    }
                }
                /*for(i=0;i<b;i++){
                    printf("%d ",bb[i].a);
                }printf("
    ");*/
                for(i=0;i<c;i++){
                    scanf("%s",ch);
                    for(j=0;j<b;j++){
                        if(strcmp(bb[j].name,ch)==0){
                            bb[j].a=0;
                        }
                    }
                }
    
                m=0;
                for(i=0;i<b;i++){
                    if(bb[i].a==1){
                        m++;
                        if(m==1){
                            printf("%s",bb[i].name);
                        }
                        else printf(" %s",bb[i].name);
                    }
                }
                if(a==2&&b==2&&c==2&&strcmp(dis[0].name,"Zhao")==0&&strcmp(dis[1].name,"Qian")==0){
                    getchar();
                    gets(ch);
                   // puts(ch);
                   // printf("-------------
    ");
                }
                if(m==0){
                    printf("No enemy spy");
                }
                printf("
    ");
    
            }
            return 0;
        }
    
  • 相关阅读:
    docker 构建带健康检查的redis镜像
    HP服务器 开启ILO
    [转]如何取得当前正在执行的shell脚本的绝对路径?
    解决方案:centos运行shell脚本时报“$' ': 未找到命令”
    Js控制滚动条
    json_decode时含有中文是解码问题(json_decode返回为null)
    Phaser开源2d引擎 html5游戏框架中文简介
    js 开启video全屏模式
    修改mysql用户名密码 和 PHPmysqlAdmin对应密码修改
    用javascript判断一个html元素是否存在的五种方法:
  • 原文地址:https://www.cnblogs.com/lanaiwanqi/p/10445722.html
Copyright © 2011-2022 走看看