「Luogu2264」情书
传送门
Luogu
解题思路
字符串模拟SB题,STL随便搞。
详情见代码。
细节注意事项
- STL总得会吧。
参考代码
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <string>
#include <set>
#define rg register
using namespace std;
set < string > s1, s2;
int main() {
#ifndef ONLINE_JUDGE
freopen("cpp.in", "r", stdin);
freopen("cpp.out", "w", stdout);
#endif
int n; cin >> n;
string a;
for (rg int i = 1; i <= n; ++i) {
cin >> a;
for (rg int x = 0; x < a.size(); ++x) a[x] = tolower(a[x]);
s1.insert(a);
}
char c = getchar();
a.clear();
int ans = 0;
while ((c = getchar()) != EOF) {
if (c == '\n') break;
if (isalpha(c)) a += tolower(c);
else {
if (!a.empty()) {
if (s1.count(a)) s2.insert(a); a.clear();
}
if (c == '.') ans += s2.size(), s2.clear();
}
}
cout << ans << endl;
return 0;
}
完结撒花 \(qwq\)