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. 为什么逻辑斯特回归(logistic regression)是线性模型

    一个典型的logistic regression模型是: 这里明明用了非线性函数,那为什么logistic regression还是线性模型呢? 首先,这个函数不是f(y,x)=0的函数,判断一个模型 ...

  2. java基础知识总结8(数据库篇1)

    一. Oracle的安装(windowXP.win7.Linux)和卸载 1.1 Oracle的安装 1.1.1 在WindowsXP.Win7下安装 第一:解压win32_11gR2_databas ...

  3. yii2.0操作数据库

    首先不得不说yii2.0面向对象的比较彻底,建议没学过或者没学好面向对象的同学再看看面向对象. 其次切入正题. 先创建数据库,这步自己写. DROP TABLE IF EXISTS `country` ...

  4. 线程本地变更,即ThreadLocal-->Spring事务管理

    我们知道Spring通过各种模板类降低了开发者使用各种数据持久技术的难度.这些模板类都是线程安全的,也就是说,多个DAO可以复用同一个模板实例而不会发生冲突.我们使用模板类访问底层数据,根据持久化技术 ...

  5. 目标检测YOLOv1-v3——学习笔记

    Fast RCNN更准一些.其损失函数比YOLO简单. YOLO更快 YOLO(You Only Look Once) 简介: 测试过程: 训练过程: 坐标.含有.不含.类别预测 目标检测的效果准确率 ...

  6. Git------Commit和Push的区别

    转载:http://wenda.so.com/q/1435946424728324?src=140 git作为支持分布式版本管理的工具,它管理的库(repository)分为本地库.远程库. git ...

  7. android最新版 极光推送

    极光推送对于移动开发的程序员都不陌生,用起来也挺方便的,今天在这里给大家介绍下最先版的极光推送的用法,超级简单. 1.在build.gradle里面添加两个方法并引用一个库文件 1.1在default ...

  8. iOS开发经验总结(一)

    本文转载至 :http://dreamahui.iteye.com/blog/1878650 软件开发方面 1.  在每个页面的入口和出口(一般是viewDidLoad和dealloc)打上日志,可以 ...

  9. Java反序列化漏洞的挖掘、攻击与防御

    一.Java反序列化漏洞的挖掘 1.黑盒流量分析: 在Java反序列化传送的包中,一般有两种传送方式,在TCP报文中,一般二进制流方式传输,在HTTP报文中,则大多以base64传输.因而在流量中有一 ...

  10. JavaScript面向对象OOP思想Class系统

    JavaScript的Class模块,纯天然无依赖,只有2k大小,快速高效,让我们优雅的面向对象... | |目录 1源码:jClass.js 2源码:jClass.min.js 3构建一个类 4访问 ...