AcWing 3688. 集合交并
原题链接
简单
作者:
yu_505
,
2024-10-17 12:03:37
,
所有人可见
,
阅读 2
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
unordered_map<int, int> mp1;
unordered_map<int, int> mp2;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
if (mp1[a] >= 1) continue;
else mp1[a]++;
}
for (int j = 0; j < m; ++j) {
int b;
cin >> b;
if (mp2[b] >= 1) continue;
else mp2[b]++;
}
int cnt1 = 0;
for (auto& [x, y] : mp1) {
if (mp2[x] == 1) {
cnt1++;
}
else mp2[x] = 1;
}
cout << cnt1 << " " << mp2.size() << endl;
return 0;
}