AcWing 5720. 相似度计算
原题链接
简单
作者:
νοιδ
,
2024-07-24 08:48:40
,
所有人可见
,
阅读 14
考场写的,来这里贴一下
#include <iostream>
#include <map>
#include <string>
using namespace std;
int n, m;
map<string, int> a, b, total;
void to_lower(string& str){
for (int i = 0; i < str.size(); i ++ ){
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] = str[i] - 'A' + 'a';
}
}
int main()
{
cin >> n >> m;
string str;
for (int i = 0; i < n; i ++ )
{
cin >> str;
to_lower(str);
a[str] ++;
total[str] ++;
}
for (int i = 0; i < m; i ++ )
{
cin >> str;
to_lower(str);
b[str] ++;
total[str] ++;
}
int cnt = 0;
map<string, int>::iterator it;
for (it = a.begin(); it != a.end(); it ++){
if (b.find(it->first) != b.end()) cnt ++;
}
cout << cnt << endl << total.size();
return 0;
}