1121 Damn Single (25 分)

"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤ 50,000), the total number of couples. Then N lines of the couples follow, each gives a couple of ID's which are 5-digit numbers (i.e. from 00000 to 99999). After the list of couples, there is a positive integer M (≤ 10,000) followed by M ID's of the party guests. The numbers are separated by spaces. It is guaranteed that nobody is having bigamous marriage (重婚) or dangling with more than one companion.

Output Specification:

First print in a line the total number of lonely guests. Then in the next line, print their ID's in increasing order. The numbers must be separated by exactly 1 space, and there must be no extra space at the end of the line.

Sample Input:

3
11111 22222
33333 44444
55555 66666
7
55555 44444 10000 88888 22222 11111 23333

Sample Output:

5
10000 23333 44444 55555 88888

题意:找出谁是“单身狗”。。。先输入各对CP,然后再输入参加party的人员,统计输入的这些人里哪些是没有CP一起来的,升序输出。

分析:水题。。我思路是用一个数组couple,初始化为-1(因为人的编号为00000-99999),作用是来存储某人的CP,如11111的CP是22222,那么couple[11111]=22222,couple[22222]=11111。最后因为要格式输出,不知道迭代器怎么格式输出。。就先把结果存到了vector中,具体见代码
 /**
 * Copyright(c)
 * All rights reserved.
 * Author : Mered1th
 * Date : 2019-02-27-21.51.47
 * Description : A1121
 */
 #include<cstdio>
 #include<cstring>
 #include<iostream>
 #include<cmath>
 #include<algorithm>
 #include<string>
 #include<unordered_set>
 #include<map>
 #include<vector>
 #include<set>
 using namespace std;
 ;
 };
 int main(){
 #ifdef ONLINE_JUDGE
 #else
     freopen("1.txt", "r", stdin);
 #endif
     int n,m,u,v,t;
     scanf("%d",&n);
     ;i<n;i++){
         scanf("%d%d",&u,&v);
         couple[u]=v;
         couple[v]=u;
     }
     scanf("%d",&m);
     vector<int> tem;
     ;i<m;i++){
         scanf("%d",&t);
         tem.push_back(t);
     }
     set<int> ans;
     ;i<m;i++){
         int coup=couple[tem[i]];
         ) ans.insert(tem[i]);
         else{
             if(find(tem.begin(),tem.end(),coup)==tem.end()){
                 ans.insert(tem[i]);
             }
         }
     }
     cout<<ans.size()<<endl;
     vector<int> res;
     for(auto it=ans.begin();it!=ans.end();it++){
         res.push_back(*it);
     }
     ;i<res.size();i++){
         printf("%05d",res[i]);
         ) printf(" ");
     }
     ;
 }

1121 Damn Single (25 分)的更多相关文章

  1. PAT甲级 1121. Damn Single (25)

    1121. Damn Single (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue "Dam ...

  2. 1121. Damn Single (25)

    "Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are suppo ...

  3. PAT甲题题解-1121. Damn Single (25)-水题

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789787.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  4. PTA 1121 Damn Single

    题目链接:1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who i ...

  5. PAT 1121 Damn Single[简单]

    1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who is bei ...

  6. 1016 Phone Bills (25 分)

    1016 Phone Bills (25 分) A long-distance telephone company charges its customers by the following rul ...

  7. A1016 Phone Bills (25)(25 分)

    A1016 Phone Bills (25)(25 分) A long-distance telephone company charges its customers by the followin ...

  8. PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)

    1024 Palindromic Number (25 分)   A number that will be the same when it is written forwards or backw ...

  9. PAT 甲级 1017 Queueing at Bank (25 分)(模拟题,有点思维小技巧,第二次做才理清思路)

    1017 Queueing at Bank (25 分)   Suppose a bank has K windows open for service. There is a yellow line ...

随机推荐

  1. NIO 多人聊天室

    一前言 在家休息没事,敲敲代码,用NIO写个简易的仿真聊天室.下面直接讲聊天室设计和编码.对NIO不了解的朋友,推荐一个博客,里面写的很棒: https://javadoop.com/     里面有 ...

  2. NK实习项目配置

    1.复制eclipse和项目 2.配置tomcat6,现在只能用tomcat6 3.tomcat6插件eclipse是默认有的,只需要配置一下 http://blog.csdn.net/u014079 ...

  3. confluence 为合并的单元格新增一行

    1,先将最后一个结构取消合并单元格 |    | ___ | |    | ___ | | _ | ___ | 2,在最后一行追加一行,将左侧合并 3,将上面取消合并的重新合并即可

  4. <--------------------------Java接口如何使用------------------------------>

    关键词:interface --->接口      implements--->实现 1接口的概念 接口是功能的集合,同样可看做是一种数据类型,是比抽象类更为抽象的”类”. 接口只描述所应 ...

  5. spring中afterPropertiesSet方法与init-method配置描述

    1. InitializingBean.afterPropertiesSet()Spring中InitializingBean接口类为bean提供了定义初始化方法的方式,它仅仅包含一个方法:after ...

  6. 在单文件组件中,引入安装模块里的css的2种方式:script中引入、style中引入

    在单文件组件中,引入安装模块里的css的2种方式:script中引入.style中引入 1.script中引入 <script> import 'bulma/css/bulma.css' ...

  7. 【转】EF Code First 学习笔记:约定配置

    要更改EF中的默认配置有两个方法,一个是用Data Annotations(在命名空间System.ComponentModel.DataAnnotations;),直接作用于类的属性上面;还有一个就 ...

  8. golang bug Unknown load command 0x32 (50)

    问题 编译文件时报错: /usr/local/go/pkg/tool/darwin_amd64/link: /usr/local/go/pkg/tool/darwin_amd64/link: comb ...

  9. Linux crontab配置

    crontab配置 1.命令功能 通过crontab 命令,我们可以在固定的间隔时间执行指定的系统指令或 shell script脚本.时间间隔的单位可以是分钟.小时.日.月.周及以上的任意组合.这个 ...

  10. less命令详解

    Linux less命令 less 与 more 类似,但使用 less 可以随意浏览文件,而 more 仅能向前移动,却不能向后移动,而且 less 在查看之前不会加载整个文件 语法: less [ ...