So easy

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 991    Accepted Submission(s): 547

Problem 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 a1,a2,a3,…,an - represents the content of the first file. The third line contains n integers b1,b2,b3,…,bn - represents the content of the second file.
Process to the end of file.
1≤n≤100
1≤ai,bi≤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
 
水题……
 //2016.8.12
#include<iostream>
#include<cstdio>
#include<set> using namespace std; int main()
{
int n;
while(cin>>n)
{
set<int> seta;
set<int> setb;
int a, b;
bool fg = true;
for(int i = ; i < n; i++)
{
scanf("%d", &a);
seta.insert(a);
}
for(int i = ; i < n; i++)
{
scanf("%d", &b);
setb.insert(b);
}
if(seta.size()!=setb.size())
fg = false;
else{
set<int>::iterator it;
for(it = seta.begin(); it != seta.end(); it++)
{
if(setb.count(*it)==)
fg = false;
}
}
if(fg)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
} return ;
}

HDU5058的更多相关文章

随机推荐

  1. oracle与SqlServer连接串服务器地址

    SQLSERVER数据库可在连接串中指定服务器: ORACLE在监听中指定服务器地址.

  2. 多线程编程--- __thread关键字

    __thread是GCC内置的线程局部存储设施,存取效率可以和全局变量相比.__thread变量每一个线程有一份独立实体,各个线程的值互不干扰.可以用来修饰那些带有全局性且值可能变,但是又不值得用全局 ...

  3. octave之奇巧淫技向量化计算实现寻找样本点所属聚类下标

    前面有文章提到过,K-means算法,第一步骤是找出样本点的的所属聚类.下面用两种方式实现,一种是普通的循环,一种是完全向量化计算. 假设 : X 是m×n样本矩阵,其每一行是一个样本,m表示样本数目 ...

  4. mysql 千万量级的表的优化

    参考: 一  大的优化方向: 数据结构优化,慢查询优化,索引优化,mysql参数设置优化 数据结构优化:先读写分离.再垂直拆分.再水平拆分! 说3点 1. 设计合适的索引,基于主键的查找,上亿数据也是 ...

  5. Photoshop安装

    作者:郑超 参考地址:http://bbs.weiphone.com/read-htm-tid-4594713.html 下载地址:http://www.adobe.com/downloads.htm ...

  6. 常见div+css网页布局(float,absolute)

    网页布局-常见 1,           float布局 (1)常规方法 <div id="warp">     <div id="column&quo ...

  7. WCF中传递对象的成员变量行不通?

    今早通过WCF服务添加对象到数据库,有一个变量始终没有传过来 定义: public bool isLogin; 修改成 private bool _isLogin; public bool isLog ...

  8. jquery弹窗插件

    .zhuti { position:absolute; z-index:; font-size:14px; border-radius:5px; box-shadow: 5px white; over ...

  9. IOS开发中长按的手势事件编程

    长按手势事件: 长按按钮1S后改变按钮颜色: // 长按事件 #import "ViewController.h" @interface ViewController (){ UI ...

  10. java 对象比较

    class Book{    private String title ;    private double price ; public Book(String title , double pr ...