HDU 5058 so easy (set container algorithm is good)

Source: Internet
Author: User

Link: HDU 5058So easy

Question: give two sequences and ask if the two sequences constitute the same set,


Set Method is good!


AC code:


# Include <stdio. h >#include <set ># include <map> using namespace STD; # define ll _ int64set <ll> SS1, ss2; set <ll >:: iterator it; int main () {ll N, I; while (scanf ("% i64d", & N )! = EOF) {ll num; ss1.clear (); ss2.clear (); for (I = 0; I <n; I ++) {scanf ("% i64d ", & num); ss1.insert (Num) ;}bool flag = true; for (I = 0; I <n; I ++) {scanf ("% i64d ", & num); ss2.insert (Num);} If (ss2.size ()! = Ss1.size () printf ("NO \ n"); else {int temp = ss1.size (); For (IT = ss2.begin (); it! = Ss2.end (); It ++) ss1.insert (* It); If (temp = ss1.size () printf ("Yes \ n "); else printf ("NO \ n") ;}} return 0 ;}


HDU 5058 so easy (set container algorithm is good)

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.