"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 (<=50000), 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 (<=10000) 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

标记每一对情侣,然后查看有情侣的,情侣是否在场就好。 代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int love[],haslove[],loveex[],a,b,c;
int ans[],peo[],n,m;
int main()
{
cin>>n;
for(int i = ;i < n;i ++)
{
cin>>a>>b;
love[a] = b;
love[b] = a;
haslove[a] = ;
haslove[b] = ;
}
cin>>m;
for(int i = ;i < m;i ++)
{
cin>>peo[i];
if(haslove[peo[i]])loveex[love[peo[i]]] = ;
}
for(int i = ;i < m;i ++)
{
if(!loveex[peo[i]])ans[c ++] = peo[i];
}
sort(ans,ans + c);
cout<<c<<endl;
if(c)printf("%05d",ans[]);
for(int i = ;i < c;i ++)
printf(" %05d",ans[i]);
}

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. PAT甲题题解-1121. Damn Single (25)-水题

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

  3. PTA 1121 Damn Single

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

  4. 1121 Damn Single (25 分)

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

  5. PAT 1121 Damn Single[简单]

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

  6. PAT 1121 Damn Single

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

  7. 1121 Damn Single

    题意: 给出n对情侣,然后给出聚会上的m个人,问这m个人中有几个人事落单的. 思路: 首先,开一个数组couple[]存储情侣间的映射关系:然后,用exist[]标记聚会上出现过的人:最后遍历0~N, ...

  8. PAT1121:Damn Single

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

  9. PAT甲级题解(慢慢刷中)

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

随机推荐

  1. Oracle诊断:drop table失败[转]

    转: From <http://blog.csdn.net/cyxlxp8411/article/details/7775113> 今天在drop一张表的时候报ORA-00054错误 SQ ...

  2. maven 报错 Cannot resolve plugin org.apache.maven.plugins:maven-war-plugin:2.1.1

    主要原因是本地maven的配置文件和仓库地址不一致.

  3. Arthas随笔

    目录 Arthas 安装Java 安装 Arthas Arthas 命令及示例 源码分析 Arthas 安装Java 下载jdk 注意 下载的JDK版本要与linux操作系统相匹配,否则汇报No su ...

  4. 电商企业如何做好EDM营销随感

    对于中小型电商企业来说,运用EDM营销是一种非常不错的营销方式,正如我在电商EDM数据营销中的关键介绍一样.下面博主给大家介绍一下电商企业如何做好EDM营销. 一.在EDM邮件内容中跟客户建立信任的关 ...

  5. centos7 ngxin启动失败:Job for nginx.service failed(80端口被占用的解决办法)

    问题描述:(flaskApi) [root@67 flaskDemo]# service nginx start Redirecting to /bin/systemctl start nginx.s ...

  6. Html/CSS 示例演练 图书馆后台界面

    示例演练(html css javascript) --制作图书馆后台界面 1. 成品图

  7. webpack bundle中parentJsonpFunction的作用

    parentJsonpFunction作用:使异步加载的模块在多个不同的bundle内同步. 假设有多入口文件 bundle1.js: bundl2.js: 在webpack打包后 加载流程: 1.b ...

  8. 【HANA系列】SAP HANA 2.0简介

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA 2.0简介   ...

  9. itchat监听微信撤回消息

    import itchat from itchat.content import * import re msg_infomation = {} # 监听发送消息 @itchat.msg_regist ...

  10. [DS+Algo] 009 树的介绍

    目录 1. 树的概念 2. 树的术语 3. 树的种类 4. 常见应用场景 5. 二叉树 1. 树的概念 每个结点(节点)有 0 个或多个子结点 没有父结点的结点称为根结点 每一个非根结点有且只有一个父 ...