-
[14425] 문자열 집합BOJ 2022. 3. 15. 06:44
https://www.acmicpc.net/problem/14425
14425번: 문자열 집합
첫째 줄에 문자열의 개수 N과 M (1 ≤ N ≤ 10,000, 1 ≤ M ≤ 10,000)이 주어진다. 다음 N개의 줄에는 집합 S에 포함되어 있는 문자열들이 주어진다. 다음 M개의 줄에는 검사해야 하는 문자열들이 주어
www.acmicpc.net
set<string>에 n개를 넣고, m개의 string에 대해 (set.count()==1)를 누적한다.
#include <bits/stdc++.h>using namespace std;#ifdef ONLINE_JUDGEconstexpr bool local = false;#elseconstexpr bool local = true;#endifusing ll = long long;using pi = pair<ll, ll>;int n, m, ans;set<string> st;int main(void) {if (!local) ios_base::sync_with_stdio(0), cin.tie(0);cin >> n >> m;int i;for (i = 0; i < n; i++) {string s;cin >> s;st.insert(s);}for (i = 0; i < m; i++) {string s;cin >> s;ans += (st.count(s) == 1);}cout << ans;return 0;}
'BOJ' 카테고리의 다른 글
[10282] 해킹 (0) 2022.03.22 [2447] 별 찍기 - 10 (0) 2022.03.18 [1445] 일요일 아침의 데이트 (0) 2022.03.13 [2304] 창고 다각형 (0) 2022.03.12 [17135] 캐슬 디펜스 (0) 2022.03.12