BestCoder ::So easy
来源:互联网 发布:无缝丝袜淘宝贴吧 编辑:程序博客网 时间:2024/05/16 17:53
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.
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
31 1 21 2 245 3 7 77 5 3 342 5 2 32 5 2 531 2 31 2 4
Sample Output
YESYESNONO
Source
BestCoder Round #12
题意为:给你两组数据,看看这两组数据去重复后是否完全相同,相同输出yes,不相同输出no,所以想到的是用容器去重复
#include<stdio.h>#include<iostream>#include<algorithm>#include<vector>using namespace std;int main(){ int n; vector<int > a1; vector<int > a2; while(scanf("%d",&n)!=EOF) { a1.clear();//清空容器 a2.clear(); int i; int temp; int flag=0; for(i=0;i<n;i++) { scanf("%d",&temp); a1.push_back(temp);//将数据放入容器 } for(i=0;i<n;i++) { scanf("%d",&temp); a2.push_back(temp); } sort(a1.begin(),a1.end());//对数据进行排序 sort(a2.begin(),a2.end()); vector <int > ::iterator it=unique(a1.begin(),a1.end()); a1.erase(it,a1.end());//运用这两句进行去重复 vector <int > ::iterator it1=unique(a2.begin(),a2.end()); a2.erase(it1,a2.end()); if(a1.size()!=a2.size()) { printf("NO\n"); } else { int i; for(i=0;i<a1.size();i++) { if(a1[i]!=a2[i])//将数据进行比较 { flag=1; break; } } if(flag==0) printf("YES\n"); else if(flag==1) printf("NO\n"); } } return 0;}
0 0
- BestCoder ::So easy
- 20141006 【 STL 】 bestcoder #12 So easy
- Bestcoder Div2 #77 A So easy
- BestCoder Round #77 (div.2) 1001 so easy
- 【BestCoder Round #77 (div.2)】so easy(水)
- BestCoder Round #77 (div.2) -so easy(组合)
- Hdu 5650 so easy (BestCoder Round #77 (div.2 A))
- So Easy!
- so easy
- so easy
- So Easy!
- 【HDU5650 BestCoder Round 77 (div2) A】【水题】so easy 集合所有子集异或和的异或和
- 数据库对象so easy
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- 程序员的这108个笑话 都能看懂的技术应该不会太差!
- 拷贝构造函数和赋值运算符有哪些不同点和相同点
- TED如何和压力做朋友(第四天完)
- 旅游问题
- tp的验证码的验证
- BestCoder ::So easy
- centos7下调试集群三台机器实现免密登陆--hadoop安装系列之一
- 【书山有路】SQL必知必会 第10课
- 《Linux内核分析》MOOC课程第六次实验作业
- 一种排序
- navicat导入sql文件太慢,mysql直接导入解决
- C# 调用微软自带的语音识别
- ZOJ-3711-Give Me Your Hand【概率dp】【10th浙江省赛】【好题】
- HDU3308区间合并+单点更新