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 分)的更多相关文章

  1. PAT甲级 1121. Damn Single (25)

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

  2. 1121. Damn Single (25)

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

  3. PAT甲题题解-1121. Damn Single (25)-水题

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

  4. PTA 1121 Damn Single

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

  5. PAT 1121 Damn Single[简单]

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

  6. 1016 Phone Bills (25 分)

    1016 Phone Bills (25 分) A long-distance telephone company charges its customers by the following rul ...

  7. A1016 Phone Bills (25)(25 分)

    A1016 Phone Bills (25)(25 分) A long-distance telephone company charges its customers by the followin ...

  8. PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)

    1024 Palindromic Number (25 分)   A number that will be the same when it is written forwards or backw ...

  9. 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 ...

随机推荐

  1. 《DSP using MATLAB》Problem5.16

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. BootStrap------之模态框1

    <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8& ...

  3. centos7.3使用花生壳映射端口

    首先下载花生壳客户端(其实我觉得更应该叫做服务端),选择相应的版本就可,例如我就是选择的linux->centos版本的 https://hsk.oray.com/download/ 我的版本为 ...

  4. openresty 编译ngx_pagespeed 模块-docker 构建

    ngx_pagespeed 是一个很不错的web 优化模块,我们通过简单的配置就可以对于web页面的加载有很大的提升 ngx_pagespeed 依赖psol 模块 Dockerfile   # Do ...

  5. 记一次接口504 Gateway Time-out原因及解决方法

    今天在刷新公司项目页面时发现有个板块一直刷新不出数据,最后发现接口报错(504 Gateway Time-out) 通过查看代码发现有个sql语句,如下,特别慢 select `vdc1`,      ...

  6. [转]MyBatis中resultType与resultMap区别

    MyBatis中关于resultType和resultMap的具体区别如下: MyBatis中在查询进行select映射的时候,返回类型可以用resultType,也可以用resultMap.resu ...

  7. bzoj 2553 [BeiJing2011]禁忌——AC自动机+概率DP+矩阵

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2553 看了题解才会…… 首先,给定一个串,最好的划分方式是按禁忌串出现的右端点排序,遇到能填 ...

  8. Hive DDL及DML操作

    一.修改表 增加/删除分区 语法结构 ALTER TABLE table_name ADD [IF NOT EXISTS] partition_spec [ LOCATION 'location1' ...

  9. CentOS 6.5 下源码搭建LAMP环境

    参考网站: http://wenku.baidu.com/link?url=Cvkqss2E9mnxXOZigMWPaCfqwsBxnm0sZ4aKE2oLAgQ888XxeC0DWOChxVqiHz ...

  10. RedHat7.3安装MySQL5.7

    1.下载Mysql安装包 https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar 附百度 ...