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
题意:找出谁是“单身狗”。。。先输入各对CP,然后再输入参加party的人员,统计输入的这些人里哪些是没有CP一起来的,升序输出。
分析:水题。。我思路是用一个数组couple,初始化为-1(因为人的编号为00000-99999),作用是来存储某人的CP,如11111的CP是22222,那么couple[11111]=22222,couple[22222]=11111。最后因为要格式输出,不知道迭代器怎么格式输出。。就先把结果存到了vector中,具体见代码
/**
* Copyright(c)
* All rights reserved.
* Author : Mered1th
* Date : 2019-02-27-21.51.47
* Description : A1121
*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<map>
#include<vector>
#include<set>
using namespace std;
;
};
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
int n,m,u,v,t;
scanf("%d",&n);
;i<n;i++){
scanf("%d%d",&u,&v);
couple[u]=v;
couple[v]=u;
}
scanf("%d",&m);
vector<int> tem;
;i<m;i++){
scanf("%d",&t);
tem.push_back(t);
}
set<int> ans;
;i<m;i++){
int coup=couple[tem[i]];
) ans.insert(tem[i]);
else{
if(find(tem.begin(),tem.end(),coup)==tem.end()){
ans.insert(tem[i]);
}
}
}
cout<<ans.size()<<endl;
vector<int> res;
for(auto it=ans.begin();it!=ans.end();it++){
res.push_back(*it);
}
;i<res.size();i++){
printf("%05d",res[i]);
) printf(" ");
}
;
}
1121 Damn Single (25 分)的更多相关文章
- PAT甲级 1121. Damn Single (25)
1121. Damn Single (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue "Dam ...
- 1121. Damn Single (25)
"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are suppo ...
- 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 ...
- PAT 1121 Damn Single[简单]
1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who is bei ...
- 1016 Phone Bills (25 分)
1016 Phone Bills (25 分) A long-distance telephone company charges its customers by the following rul ...
- A1016 Phone Bills (25)(25 分)
A1016 Phone Bills (25)(25 分) A long-distance telephone company charges its customers by the followin ...
- PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)
1024 Palindromic Number (25 分) A number that will be the same when it is written forwards or backw ...
- PAT 甲级 1017 Queueing at Bank (25 分)(模拟题,有点思维小技巧,第二次做才理清思路)
1017 Queueing at Bank (25 分) Suppose a bank has K windows open for service. There is a yellow line ...
随机推荐
- functional program language
1.什么是函数式编程语言 函数式语言(functional language)一类程序设计语言,是一种非冯·诺伊曼式的程序设计语言.函数式语言主要成分是原始函数.定义函数和函数型.这种语言具有较强的组 ...
- <--------------------------StringBuffer的常用方法------------------------------>
StringBuffer定义: 是可变字符数组,是线程安全的可变字符序列. StringBuffer和String的区别: String是一个不可变的字符序列. 实例: public class St ...
- SolrCore Initialization Failures - Max direct memory is likely too low
org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: The max direct memory is ...
- 人教版高中数学(A版)
必修1 (已看) 第一章 集合与函数概念 1.1 集合 1.2 函数及其表示 1.3 函数的基本性质 第二章 基本初等函数(1) 2.1 指数函数 2.2 对数函数 2.3 幂函数 第三章 函数的应用 ...
- Debug outlook add-in (office.js) 小技巧
这几天在使用office.js 做outlook add-in的时候出现了一个问题: 不知道运行时去调试. 这里给大家介绍两个调试add-in 的方法. office365 其他软件 add-ins ...
- ~ # himm -sh: himm: not found的解决方法
ls /bin发现没有himm 海思根文件默认没有把himm工具集成在bin里,但是在sdk中 /home/swann/Hi3516CV300_SDK_V1.0.3.0/osdrv/tools/boa ...
- springboot获得应用上下文
有的兄弟说需要在启动类中注入,但我暂时不用
- 洛谷 3295 [SCOI2016]萌萌哒——并查集优化连边
题目:https://www.luogu.org/problemnew/show/P3295 当要连的边形如 “一段区间内都是 i 向 i+L 连边” 的时候,用并查集优化连边. 在连边的时候,如果要 ...
- VMWare虚拟机安装 - 学习者系列文章
以前笔者写过一个VMWare虚拟机的安装说明,但是那个版本比较低,已经过时,今天,讲讲VMWare的14版本的安装和使用说明. 首先,下载VMWare 14的安装文件,这里提供一下百度网盘文件: 链接 ...
- C# 装箱
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...