"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. Java定时器Timer

    Java定时器Timer在JDK库中,Timer类主要负责计划任务的功能,也就是在指定的时开始执行某一个任务.Timer类的主要作用就是设置计划任务,但封装任务的类却是TimerTask类,执行计划任 ...

  2. 003-Django创建模版配置流程

    创建一个页面,简单的 templates/新建home.html,首页展示个人信息,发现我们需要四个参数 <!DOCTYPE html> <html lang="en&qu ...

  3. 阿里云 centos 部署 Django 可能遇到的问题

    问题一:版本限制   File "/Users/icourt/Desktop/hf/venv/lib/python3.7/site-packages/django/db/backends/m ...

  4. cocos2dx基础篇(14) 滚动视图CCScrollView

    [3.x]     (1)去掉 "CC"     (2)滚动方向         > CCScrollViewDirection 改为强枚举 ScrollView::Dire ...

  5. EFI系统分区如何删除

    U盘或者硬盘被做了系统安装盘. 结果在格式化都是失败,分区也不行. 有了新招 EFI分区是您的系统启动引导的分区,存放引导启动的文件的,因此它是一个操作系统独立的分区,实际上它是UEFI加载的固件和应 ...

  6. centos7 VM虚拟机在主机关机重启后,无法ping通

    解决办法 1.虚拟机的某些网络相关的服务没有启动,打开电脑的服务启动相关服务 2.打开虚拟机的虚拟网络设置,恢复默认设置即可 3.判定虚拟网卡的网关和centos的网关是否一致,如果不一致,改成一致, ...

  7. 配置DHCP中继

    本实验模拟企业网络场景.某公司分部的网络由交换机S1和网关路由器R1组成,员工终端PC-1和PC-2都连接在S1上.公司要求分部内所有员工主机的IP地址都通过总部的DHCP服务器自动获取.分部网关路由 ...

  8. [转帖]16nm国内最先进 兆芯展示x86 KX-6000八核处理器

    16nm国内最先进 兆芯展示x86 KX-6000八核处理器 https://www.cnbeta.com/articles/tech/847125.htm 在近日的2019北京国际互联网科技博览会暨 ...

  9. 各类最新Asp .Net Core 项目和示例源码

    1.网站地址:http://www.freeboygirl.com2.网站Asp .Net Core 资料http://www.freeboygirl.com/blog/tag/asp%20net%2 ...

  10. Luogu P1315 [NOIP2012]观光公交

    题目 每次把加速器用在可以是答案减少最多的地方就即可.(这不是废话吗?) 具体而言,我们处理出: \(sum_i\)到\(i\)为止下车人数之和. \(t_i\)在\(i\)最晚的上车的人的上车时间. ...