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 (<=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)的更多相关文章
- PAT甲级 1121. Damn Single (25)
1121. Damn Single (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue "Dam ...
- PAT甲题题解-1121. Damn Single (25)-水题
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789787.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PTA 1121 Damn Single
题目链接:1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who i ...
- 1121 Damn Single (25 分)
1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who is bei ...
- PAT 1121 Damn Single[简单]
1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who is bei ...
- PAT 1121 Damn Single
"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are suppo ...
- 1121 Damn Single
题意: 给出n对情侣,然后给出聚会上的m个人,问这m个人中有几个人事落单的. 思路: 首先,开一个数组couple[]存储情侣间的映射关系:然后,用exist[]标记聚会上出现过的人:最后遍历0~N, ...
- PAT1121:Damn Single
1121. Damn Single (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue "Dam ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
随机推荐
- a标签点击,页面自动刷新
<a href="javascript:void(0)" id="reDiagnosis" class="checkBtn"oncli ...
- Mybaits基本的CURD操作
1 首先在Mapper.xml配置 <!-- parameterType:参数类型,可以省略, 获取自增主键的值: mysql支持自增主键,自增主键值的获取,mybatis也是利用stateme ...
- Linux_进程管理&计划任务
目录 目录 top打开Linux系统任务管理控制台 ps进程查询指令 kill进程关闭指令 一个小实验 一次性计划任务 周期性计划任务 top打开Linux系统任务管理控制台 快捷键: P M k q ...
- 子系统安装nginx
Win10中启用WSL WSL是微软和Canonical合作为开发人员提供的一个运行在win10环境下的一个Linux子系统,由微软编写核心代码,并由Canonical提供软件包的支持.要想使用WSL ...
- 阶段3 1.Mybatis_12.Mybatis注解开发_1 mybatis注解开发的环境搭建
注解开发是省了IUserDao.xml这个映射文件里面的配置 环境搭建 首先是packaging标签.输入jar 需要准备一个实体类.生成getter和setter还有toString方法 创建dao ...
- 阶段3 1.Mybatis_06.使用Mybatis完成DAO层的开发_1 Mybatis中编写dao实现类的使用方式-查询列表
就是自己写实现类的方式来开发 直接finish 把之前写的CRUD的代码复制到过来. 在把之前pom.xml里面的包的依赖也复制过来 复制到当前的pom.xml内 允许自动导入 以上步骤就是复制了一个 ...
- 阶段3 1.Mybatis_05.使用Mybatis完成CRUD_4 Mybatis的CRUD-查询一个和模糊查询
模糊查询 测试的时候需要提供百分号的模糊查询.传入的参数提供百分号 所有包含王字的就都查询出来了.
- 5.2.k8s.Secret
#Secret Secret存储密码.token.密钥等敏感数据 Secret以Volume或环境变量方式使用 #Secret类型 Opaque : base64 编码格式的 Secret kuber ...
- SPA(single page application)
一.SPA的概述 SPA(single page application)单页面应用程序,在一个完成的应用或者站点中,只有一个完整的html页面,这个页面有一个容器,可以把需要加载的代码片段插入到该容 ...
- Java回调机制的理解
用一句话讲明回调机制就是,在A类里面拥有一个类B的对象,调用B类的某个方法并把自身引用传入,在B类的这个方法里面又通过传进来的A的引用来调用A类的某个方法(这个最后调用的A类的方法就叫做回调方法). ...