Recent Posts
Notice
No Rules Rules
문자열 집합 (feat. 백준, 14425번) 본문
728x90
반응형
문자열 집합
https://www.acmicpc.net/problem/14425
14425번: 문자열 집합
첫째 줄에 문자열의 개수 N과 M (1 ≤ N ≤ 10,000, 1 ≤ M ≤ 10,000)이 주어진다. 다음 N개의 줄에는 집합 S에 포함되어 있는 문자열들이 주어진다. 다음 M개의 줄에는 검사해야 하는 문자열들이 주어
www.acmicpc.net
반응형
// woohyeon.kim
// https://www.acmicpc.net/problem/14425
#include <iostream>
#include <set>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
register int N, M, ans = 0;
string tmp;
set<string> S;
cin >> N >> M;
for (register int i = 0; i < N; ++i)
cin >> tmp, S.insert(tmp);
for (register int i = 0; i < M; ++i) {
cin >> tmp;
if (S.find(tmp) != S.end())
++ans;
}
cout << ans;
return 0;
}
// *&)*@*
자료구조 set을 이용해서 검사할 문자열과 동일한 문자열이 있을 경우, 정답의 개수를 +1 해줍니다.
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
숫자 카드 2 (feat. 백준, 10816번) (0) | 2022.08.03 |
---|---|
나는야 포켓몬 마스터 이다솜 (feat. 백준, 1620번) (0) | 2022.08.03 |
숫자 카드 (feat. 백준, 10815번) (0) | 2022.08.03 |
좌표 압축 (feat. 백준, 18870번) (0) | 2022.08.03 |
나이순 정렬 (feat. 백준, 10814번) (0) | 2022.08.02 |
Comments