/*
* @Description:
* @Version: 1.0
* @Author: Jiaoz
* @Email: jiaozzzzzzzz@qq.com
* @Date: 2021-11-05 23:49:51
*/
#include <iostream>
using namespace std;
#include <set>
int main()
{
int n;
cin>>n;
set<int> arra;
set<int> arrb;
for (int i = 0;i<n;i++){
int f;
cin>>f;
arra.insert(f);
}
int m;
cin>>m;
for(int i =0;i<m;i++){
int f;
cin>>f;
arrb.insert(f);
}
if(arra == arrb){
cout<<"yes";
}
else{cout<<"no";}
system("pause");
return 0;
}
【题目描述】
给定两个集合A和B,判断他们是否相等。(集合元素可能需要去重) 。
如果两个集合相等,则输出"yes",否则输出"no"
【输入格式】
两行分别表示集合 A 和 B ,每一行先输入一个数 n 表示集合的大小,接下来输入 n 个数表示集合的元素
【输出格式】
按要求输出 "yes" 或 "no" (不带引号)
【输入样例】
4 1 2 3 4
4 4 3 2 1
【输出样例】
yes
【样例解释】
第一个集合里不重复的元素为{1,2,3,4},第二个集合也为{1,2,3,4},故两个集合相等
题目来自数组作业 偷懒了