글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자입니다

 

목차

     

     


     

     

     

    [백준 14425번 C/C++]  문자열 집합

     

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

     

    14425번: 문자열 집합

    첫째 줄에 문자열의 개수 N과 M (1 ≤ N ≤ 10,000, 1 ≤ M ≤ 10,000)이 주어진다.  다음 N개의 줄에는 집합 S에 포함되어 있는 문자열들이 주어진다. 다음 M개의 줄에는 검사해야 하는 문자열들이 주어

    www.acmicpc.net

     


     

    해결전략

     

     

     

     


     

    코드

     

    #include<iostream>
    #include<map>
    #include<string>
    using namespace std;
    
    int main() {
    	ios::sync_with_stdio(false);
    	cin.tie(NULL);
    	cout.tie(NULL);
    
    	int n, m, cnt = 0;
    	cin >> n >> m;
    
    	map<string, bool> word;
    
    	for (int i = 0; i < n; i++) {
    		string s1;
    		cin >> s1;
    		word[s1] = true;
    	}
    
    	for (int i = 0; i < m; i++) {
    		string s2;
    		cin >> s2;
    
    		if (word[s2] == true) cnt++;
    	}
    
    	printf("%d\n", cnt);
    
    	return 0;
    }