알고리즘

C++ 알고리즘 - 백준 14425 문자열 집합

마루설아 2025. 1. 11. 21:40

https://www.acmicpc.net/problem/14425

 

#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"

using namespace std;

void CPP_INIT() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main(void) {
	CPP_INIT();

	int input1, input2;
	int cnt = 0;
	string str;
	unordered_map<string, bool> um;
	cin >> input1 >> input2;

	for (int i = 0; i < input1; i++) {
		cin >> str;
		um[str] = true;
	}

	for (int i = 0; i < input2; i++) {
		cin >> str;
		if (um[str]) cnt++;
	}

	cout << cnt;
}