zoukankan      html  css  js  c++  java
  • hdu 5058 So easy

    题目连接

    http://acm.hdu.edu.cn/showproblem.php?pid=5058 

    So easy

    Description

    Small W gets two files. There are n integers in each file. Small W wants to know whether these two files are same. So he invites you to write a program to check whether these two files are same. Small W thinks that two files are same when they have the same integer set.
    For example file A contains (5,3,7,7),and file B contains (7,5,3,3). They have the same integer set (3,5,7), so they are same.
    Another sample file C contains(2,5,2,5), and file D contains (2,5,2,3).
    The integer set of C is (2,5),but the integer set of D is (2,3,5),so they are not same.
    Now you are expected to write a program to compare two files with size of n.

    Input

    Multi test cases (about 100). Each case contain three lines. The first line contains one integer n represents the size of file. The second line contains n integers
    $a_1, a_2, a_3, ldots, a_n$ - represents the content of the first file. The third line contains n integers $b_1, b_2, b_3, ldots, b_n$ - represents the content of the second file.
    Process to the end of file.
    $1 leq n leq 100$
    $1 leq a_i , b_i leq 1000000000$

    Output

    For each case, output "YES" (without quote) if these two files are same, otherwise output "NO" (without quote).

    Sample Input

    3
    1 1 2
    1 2 2
    4
    5 3 7 7
    7 5 3 3
    4
    2 5 2 3
    2 5 2 5
    3
    1 2 3
    1 2 4

    Sample Output

    YES
    YES
    NO
    NO

    刷些水题打发时间。。

     1 #include<cstdio>
     2 #include<set>
     3 using std::set;
     4 set<int> A, B;
     5 int main() {
     6     int n, v;
     7     while (~scanf("%d", &n)) {
     8         for (int i = 0; i < n << 1; i++) {
     9             scanf("%d", &v);
    10             if (i < n) A.insert(v);
    11             else B.insert(v);
    12         }
    13         if (A == B) puts("YES");
    14         else puts("NO");
    15         A.clear(), B.clear();
    16     }
    17     return 0;
    18 }
    View Code
    By: GadyPu 博客地址:http://www.cnblogs.com/GadyPu/ 转载请说明
  • 相关阅读:
    TechRoad_oneStep_0410
    Tech road one step
    TechRoad--oneStep--0327
    TechRoad_oneStep 0313
    Tech road one step
    Tech road one step
    Tech road one step
    Tech road one step
    Tech road one step
    Tech road one step
  • 原文地址:https://www.cnblogs.com/GadyPu/p/4561942.html
Copyright © 2011-2022 走看看