The problem of experimental 7:problem C:stl--jerry

Source: Internet
Author: User

Description recently Jerry is working hard to learn the function of set in STL, he found that set can be used in the existing functions to achieve and, intersection, difference, symmetry and other functions, but he did not find how to compare the two sets are equal function function, So he wants to use other functional functions to determine whether the two sets are equal. Clever Jerry will think of the solution, and now he wants to take this question to test you, to see if you have him smart.

Input

Input has multiple groups, each set of data has two rows, each row represents a collection, each row has several positive integers (0<d<=2147483647), and the last number of each row is 0, which represents the end of the row of data, and the end of 0 does not count toward the collection. Finally, end the input with EOF.

Output will enter a result for each set of data outputs, if the two sets are equal then outputs "YES", otherwise outputs "NO", each result occupies one row

Sample Input1 2 3 4 0 1 2 3 4 0 1 2 2 2 2 2 0 1 2 0 1 2 3 4 0 1 3 3 4 0Sample OutputYes Yes NOHINT

Symmetric difference Operation: The resulting result is the difference between the first set and the second set and the difference between the second and first
combine B and use the above tips to quickly ac!

Append Code
#include <iostream>#include<algorithm>#include<Set>using namespacestd;intMain () {intt,j;  while(cin>>t) {Set<int>A; Set<int>B; Set<int>Tmp1,tmp2,tmp3; if(t!=0) {A.insert (t);  while(cin>>t&&t!=0) A.insert (t); }         while(cin>>t&&t!=0) B.insert (t);        Set_difference (A.begin (), A.end (), B.begin (), B.end (), Inserter (TMP1, Tmp1.begin ()));        Set_difference (B.begin (), B.end (), A.begin (), A.end (), Inserter (TMP2, Tmp2.begin ()));        Set_union (Tmp1.begin (), Tmp1.end (), Tmp2.begin (), Tmp2.end (), Inserter (Tmp3, Tmp3.begin ())); if(Tmp3.empty ()) cout<<"YES"<<Endl; Elsecout<<"NO"<<Endl; }    return 0;}

The problem of experimental 7:problem C:stl--jerry

Related Article

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.