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. 在nltk中调用stanfordparser处理中文

    出现unicode decode error 解决办法是修改nltk包internals.py的java()下增加cmd的参数,cmd = ["-Dfile.encoding=UTF-8&q ...

  2. Android IBinder的linkToDeath介绍

    先看官方解释: The linkToDeath() method can be used to register a IBinder.DeathRecipient with the IBinder, ...

  3. 第三方app抽奖发送微信红包

    1.控制器方法: private string SendRedPackge(string OpenId, int Amount, string LuckyCode) { Models.PayWeiXi ...

  4. cronolog 对 tomcat 7 进行日志切割

    一.安装 软件 cronolog-1.6.2.tar.gz tar zxvf cronolog-1.6.2.tar.gz cd cronolog-1.6.2 ./configure && ...

  5. Sencha Extjs4.2 皮肤制作

    1                 UI组件基础 学习ExtJs就是学习组件的使用.ExtJs4对框架进行了重构,其中最重要的就是形成了一个结构及层次分明的组件体系,由这些组件形成了Ext的控件. E ...

  6. Ext分页之php中,真分页显示

    这是我经过很多天调试的真分页显示Ext组件 显示页面ext.php <html> <head> <meta http-equiv="Content-Type&q ...

  7. C# GridView Edit & Delete, 点击Delete的时候弹出确认框

    1. 使用GridView自带属性ShowEditButton和ShowDeleteButton,均设为True  <Columns> ... <asp:CommandField S ...

  8. JNI介绍(转)

    源:JNI介绍 JNI是在学习Android HAL时必须要面临一个知识点,如果你不了解它的机制,不了解它的使用方式,你会被本地代码绕的晕头转向,JNI作为一个中间语言的翻译官在运行Java代码的An ...

  9. c++中vector使用

    不多说,先看代码: #include <IOSTREAM> #include <VECTOR> using namespace std; int main() { cout&l ...

  10. 微信小程序-未接入app.json错误

    微信小程序建立新项目之后会出现app.json文件未接入错误如下图: 一般是因为在下图添加新项目,项目目录这一列,如果不事先建立一个空的文件夹,直接选择则不会出现quickstartup界面 所以在建 ...