Pat 1121 damn single [simple]

Source: Internet
Author: User
1121 damn single (25 points)

"Damn single (single dog)" 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.

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 (remarriage) 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:
311111 2222233333 4444455555 66666755555 44444 10000 88888 22222 11111 23333
Sample output:
510000 23333 44444 55555 88888

Question: give n couples, and then give m to those who participate in the banquet to determine how many of them are not partners to attend the banquet (they are already married, but those without a partner will also be included)

# Include <iostream> # include <vector> # include <map> using namespace STD; Map <string, string> m2f; Map <string, string> indium; int main () {int N; CIN> N; string X, Y; For (INT I = 0; I <n; I ++) {CIN> x> Y; m2f [x] = y; m2f [y] = x;} int m; CIN> m; string s; For (INT I = 0; I <m; I ++) {CIN> S; indium [s] = 1; // because the map here is naturally sorted, the final vector is also naturally sorted. } Int Ct = 0; vector <string> VT; For (Auto it = indium. Begin (); it! = Indium. end (); It ++) {string STR = it-> first; If (Indium. count (m2f [STR]) = 0) {vt. push_back (STR) ;}} cout <vt. size () <'\ n'; For (INT I = 0; I <vt. size (); I ++) {cout <VT [I]; if (I! = Vt. Size ()-1) cout <";}return 0 ;}

 

// It is relatively simple, but I submitted it twice. Why?

1. The main output format must be 1! = Vt. Size ()-1, do you know?

Pat 1121 damn single [simple]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.