http://acm.hdu.edu.cn/showproblem.php?pid=5058
set应用
水题
#include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <queue> #include <set> #include <iostream> #include <algorithm> using namespace std; #define RD(x) scanf("%d",&x) #define RD2(x,y) scanf("%d%d",&x,&y) #define clr0(x) memset(x,0,sizeof(x)) typedef long long LL; set<int> s1,s2; int x,n; void work() { s1.clear();s2.clear(); for(int i = 0;i < n;++i){ RD(x); s1.insert(x); } for(int i = 0;i < n;++i){ RD(x); s2.insert(x); } set<int>::iterator it1,it2; for(it1 = s1.begin(),it2 = s2.begin();it1 != s1.end(),it2 != s2.end();it1++,it2++){ if(*it1 != *it2){ puts("NO"); return; } } if(it1 != s1.end() || it2 != s2.end()) puts("NO"); else puts("YES"); } int main(){ while(~RD(n)){ work(); } return 0; }