【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
来源:互联网 发布:淘宝商品质量问题退钱 编辑:程序博客网 时间:2024/05/21 17:54
So easy
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 803 Accepted Submission(s): 438
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 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
Process to the end of file.
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
题意:给你两个序列,问你去重后相不相等
思路:排序去重,set的简单应用
///AC代码
/* ***********************************************┆ ┏┓ ┏┓ ┆┆┏┛┻━━━┛┻┓ ┆┆┃ ┃ ┆┆┃ ━ ┃ ┆┆┃ ┳┛ ┗┳ ┃ ┆┆┃ ┃ ┆┆┃ ┻ ┃ ┆┆┗━┓ 马 ┏━┛ ┆┆ ┃ 勒 ┃ ┆ ┆ ┃ 戈 ┗━━━┓ ┆┆ ┃ 壁 ┣┓┆┆ ┃ 的草泥马 ┏┛┆┆ ┗┓┓┏━┳┓┏┛ ┆┆ ┃┫┫ ┃┫┫ ┆┆ ┗┻┛ ┗┻┛ ┆************************************************ */#include <iostream>#include <set>#include <map>#include <stack>#include <cmath>#include <queue>#include <cstdio>#include <bitset>#include <string>#include <vector>#include <iomanip>#include <cstring>#include <algorithm>#include <functional>#define PI acos(-1)#define eps 1e-8#define inf 0x3f3f3f3f#define debug(x) cout<<"---"<<x<<"---"<<endltypedef long long ll;using namespace std;ll a[110];ll b[110];set<long long> p, q;set<long long>:: iterator piter;set<long long>:: iterator qiter;int main(){ int n; while (scanf("%d", &n) != EOF) { p.clear(); q.clear(); for (int i = 0; i < n; i++) { scanf("%lld", &a[i]); } for (int i = 0; i < n; i++) { scanf("%lld", &b[i]); } sort(a, a + n); sort(b, b + n); for (int i = 0; i < n; i++) { p.insert(a[i]); q.insert(b[i]); } if (p.size() != q.size()) { printf("NO\n"); continue; } int flag = 1; for (piter = p.begin(), qiter = q.begin(); piter != p.end(), qiter != q.end(); piter++, qiter++) { if (*piter != *qiter) { flag = 0; break; } } if (flag) { printf("YES\n"); } else { printf("NO\n"); } } return 0;}/************************************************┆ ┏┓ ┏┓ ┆┆┏┛┻━━━┛┻┓ ┆┆┃ ┃ ┆┆┃ ━ ┃ ┆┆┃ ┳┛ ┗┳ ┃ ┆┆┃ ┃ ┆┆┃ ┻ ┃ ┆┆┗━┓ ┏━┛ ┆┆ ┃ ┃ ┆ ┆ ┃ ┗━━━┓ ┆┆ ┃ AC代马 ┣┓┆┆ ┃ ┏┛┆┆ ┗┓┓┏━┳┓┏┛ ┆┆ ┃┫┫ ┃┫┫ ┆┆ ┗┻┛ ┗┻┛ ┆************************************************ */
阅读全文
0 0
- 【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
- 【CUGBACM15级BC第15场 A】hdu 5083 Love
- 【CUGBACM15级BC第17场 A】hdu 5100 Chessboard
- 【CUGBACM15级BC第23场 A】hdu 5146 Sequence
- 【CUGBACM15级BC第8场 A】hdu 4989 Summary
- 【CUGBACM15级BC第31场 A】hdu 5178 pairs
- 【CUGBACM15级BC第1场 A】hdu 4857 逃生
- HDU 5058/BC 12A So easy
- 【CUGBACM15级BC第11场 A】hdu 5054 Alice and Bob
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- 【CUGBACM15级BC第18场 A】hdu 5104 Primes Problem
- 【CUGBACM15级BC第20场 A】hdu 5123 who is the best?
- 【CUGBACM15级BC第19场 A】hdu 5108 Alexandra and Prime Numbers
- 【CUGBACM15级BC第21场 A】hdu 5138 CET-6 test
- 【CUGBACM15级BC第22场 A】hdu 5142 NPY and FFT
- 【CUGBACM15级BC第24场 A】hdu 5150 Sum Sum Sum
- 【CUGBACM15级BC第24场 C】hdu 5152 A Strange Problem
- 【CUGBACM15级BC第25场 A】hdu 5154 Harry and Magical Computer
- 主题通配符
- [游戏编程模式].(Game.Programming.Patterns).(美)Robert.Nystrom.pdf
- 数据库水平切分的实现原理解析——分库,分表,主从,集群,负载均衡器(转)
- 归并排序
- CodeIgniter框架源码学习之配置类--Config.php
- 【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
- SeetaFace开源人脸识别引擎
- ubuntu 配置静态ip && git clone ssh port 22问题 && git 全局代理
- 最短路径
- 文件I/O
- Java接收Cordys中webservice接口的返回数据并解析xml获取相应节点数据
- SVM NG机器学习
- 按图索骥法解决错误
- https