코드
#include <iostream>
#include <unordered_map> // 해시
using namespace std;
int main()
{
unordered_map<long long, int> hashmap; //long long : 집합 원소의 값 (100,000,000을 넘지 않는다.), int : 원소 값의 개수
long long a, b,ab;
int count = 0; // (A-B) 와 (B-A) 의 대칭 차집합 개수
cin >> a>>b;
for (long long i = 0; i < a+b; i++) { // 각 집합의 원소의 개수는 200,000을 넘지 않으며 -> long long
cin >> ab;
hashmap[ab]++; // 원소 값의 개수 카운트
}
for (auto n:hashmap) {
if (n.second == 1) { // 원소 값의 개수가 1인것 만 대칭 차집합에 포함
count++;
}
}
cout << count;
return 0;
}
'C++ > 백준 C++' 카테고리의 다른 글
[C/C++] 백준 11659번 구간 합 구하기 4 - 참고 (2) | 2023.11.23 |
---|---|
[C/C++] 백준 1182번 부분수열의 합 - 참고 (2) | 2023.11.23 |
[C/C++] 백준 30700번 KOREA 문자열 만들기 (2) | 2023.11.22 |
[C/C++] 백준 30684번 모르고리즘 회장 정하기 (0) | 2023.11.21 |
[C/C++] 백준 10798번 세로읽기 (0) | 2023.11.21 |