NC14330. Two Files
描述
输入描述
Multi test cases . 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≤1000000
1≤ai,bi≤1000000000
输出描述
For each case, output "YES" (without quote) if these two files are same, otherwise output "NO" (without quote).
示例1
输入:
5 1 2 1 2 3 1 3 3 2 2 3 1 2 3 1 1 2
输出:
YES NO
C++14(g++5.4) 解法, 执行用时: 156ms, 内存消耗: 9824K, 提交时间: 2020-04-03 17:34:16
#include <bits/stdc++.h> using namespace std; int main() { int q,f,i,n; while(cin>>n) { set<int>a,b; for(i=0;i<n;i++) { cin>>q; a.insert(q); } for(i=0;i<n;i++) { cin>>f; b.insert(f); } if(a==b)cout<<"YES"<<endl; else cout<<"NO"<<endl; } }
C++11(clang++ 3.9) 解法, 执行用时: 124ms, 内存消耗: 11412K, 提交时间: 2020-02-15 23:06:22
#include<bits/stdc++.h> using namespace std; int main() { int n,x,i; while(~scanf("%d",&n)) { set<int>a,b; for(i=0;i<n;i++) { scanf("%d",&x); a.insert(x); } while(n--) { scanf("%d",&x); b.insert(x); } printf("%s\n",a==b?"YES":"NO"); } return 0; }
pypy3 解法, 执行用时: 161ms, 内存消耗: 41964K, 提交时间: 2021-05-21 23:43:46
import sys while True: try: n = input() a = list(map(int,input().split())) b = list(map(int,input().split())) if set(a) == set(b): print("YES") else: print("NO") except: break
Python3(3.5.2) 解法, 执行用时: 122ms, 内存消耗: 28976K, 提交时间: 2019-01-12 22:17:53
while True: try: num=input() ls1=set(input().split()) ls2=set(input().split()) if ls1==ls2: print('YES') else: print('NO') except: break