0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 19:28:48 +00:00
OI-codes/Luogu/problem/P2264/P2264.cpp

56 lines
1.3 KiB
C++
Raw Normal View History

2021-07-09 08:37:55 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, ans = 0;
string s;
map<string, bool> m, m2;
set<string> s2;
bool flag = false;
stringstream ss;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s;
transform(s.begin(), s.end(), s.begin(), ::tolower);
m[s] = true;
}
getchar();
getline(cin, s);
transform(s.begin(), s.end(), s.begin(), ::tolower);
int pos = 0;
while (s.find('.', pos) != string::npos) {
s.insert(s.find('.', pos) + 1, " ");
pos = s.find('.', pos) + 1;
}
while (s.find(',') != string::npos) {
s.replace(s.find(','), 1, " ");
}
ss.str(s);
while (ss >> s) {
if (s.find('.') != string::npos) {
s.erase(s.find('.'));
flag = true;
}
if (s.find(',') != string::npos) {
s.erase(s.find(','));
}
for (int i = 0; i < n; i++) {
if (m[s] && !m2[s]) {
s2.insert(s);
m2[s] = true;
break;
}
}
if (flag) {
flag = false;
ans += s2.size();
s2.clear();
m2.clear();
}
s.clear();
}
cout << ans << endl;
return 0;
}