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

题目大意:给出n对情侣,然后再给出m对参加宴会的人,判断这些人当中有多少人是没有伙伴来参加宴会的(本身已经结婚,但是没带伴侣来的也会被计算进来)

#include <iostream>
#include<vector>
#include<map>
using namespace std; map<string,string> m2f;
map<string,string> inp;
int main() {
int n;
cin>>n;
string x,y;
for(int i=;i<n;i++){
cin>>x>>y;
m2f[x]=y;
m2f[y]=x;
}
int m;
cin>>m;
string s;
for(int i=;i<m;i++){
cin>>s;
inp[s]=;//因为这里的map是自然排序的,所以最终vector里也是自然排序的。
}
int ct=;
vector<string> vt;
for(auto it=inp.begin();it!=inp.end();it++){
string str=it->first;
if(inp.count(m2f[str])==){
vt.push_back(str);
}
}
cout<<vt.size()<<'\n';
for(int i=;i<vt.size();i++){
cout<<vt[i];
if(i!=vt.size()-)cout<<" ";
}
return ;
}

//还是比较简单的,但是还是提交了两次,为什么呢?

1.需要主要最后的输出格式,是1!=vt.size()-1,知道了吗?

PAT 1121 Damn Single[简单]的更多相关文章

  1. PAT 1121 Damn Single

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

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

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

  3. 1121 Damn Single (25 分)

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

  4. PTA 1121 Damn Single

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

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

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

  6. PAT 1132 Cut Integer[简单]

    1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...

  7. PAT A1121 Damn Single (25 分)——set遍历

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

  8. PAT 1089 狼人杀-简单版(20 分)(代码+测试点分析)

    1089 狼人杀-简单版(20 分) 以下文字摘自<灵机一动·好玩的数学>:"狼人杀"游戏分为狼人.好人两大阵营.在一局"狼人杀"游戏中,1 号玩家 ...

  9. [PAT]A+B Format[简单]

    1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...

随机推荐

  1. 007杰信-factory的启用+停用

    业务需求:当有一些factory与我们不在合作时,我们不能直接删除这个公司的数据,我们采用的办法是在factory_c表增加一个字段STATE(CHAR(1)),1表示是启用,0是表示停用. 准备工作 ...

  2. 第二百四十八节,Bootstrap轮播插件

    Bootstrap轮播插件 学习要点: 1.轮播插件 本节课我们主要学习一下 Bootstrap 中的轮播插件. 一.轮播 轮播插件就是将几张同等大小的大图,按照顺序依次播放. 基本实例. 第一步,给 ...

  3. MyBatis的优缺点

    优点: 1.简单易学 mybatis本身就很小且简单.没有任何第三方依赖,最简单安装只要两个jar文件+配置几个sql映射文件易于学习,易于使用,通过文档和源代码,可以比较完全的掌握它的设计思路和实现 ...

  4. mysql -- 预处理语句

    所谓预处理,即在真正执行某条SQL语句之前,先将SQL语句准备好,在执行过程中再绑定数据 语法: 准备预处理 prepare 预处理名字 from ‘要执行的SQL语句’ 执行预处理 execute ...

  5. 【BZOJ】1688: [Usaco2005 Open]Disease Manangement 疾病管理(状压dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1688 很水的状压.. 提交了很多次优化的,但是还是100msT_T #include <cst ...

  6. mysql解决乱码问题

    进入mysql(mysql -u root -p),查看当前数据库字符集(status;) 刚开始是latin1,所以乱码. vim /etc/my.cnf 两个节点添加如下: [client]def ...

  7. MyBitis(iBitis)系列随笔之三:简单实现CRUD

    Mybitis(iBitis)实现对对象增删改查操作要借助<select/>查询,<insert/>增加,<update/>更新,<delete/>删除 ...

  8. Codeforces Round #311 (Div. 2) A,B,C,D,E

    A. Ilya and Diplomas 思路:水题了, 随随便便枚举一下,分情况讨论一下就OK了. code: #include <stdio.h> #include <stdli ...

  9. MySQL------如何卸载与安装

    1.安装 转载:http://wenda.so.com/q/1471475177723102?src=140 2.卸载 转载:http://jingyan.baidu.com/article/3d69 ...

  10. 概览C++之const

    1.C语言中const与 C++中的const void main() { const int a = 10; int *p = (int*)&a; *p = 20; printf(" ...