题解
2025-08-03 22:02:05
发布于:江苏
2阅读
0回复
0点赞
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
// 存储所有暴戾性语言
vector<string> bad_words(m);
for (int i = 0; i < m; ++i) {
cin >> bad_words[i];
}
int count = 0; // 违禁词数量
// 检查每个单词
for (int i = 0; i < n; ++i) {
string word;
cin >> word;
// 检查该单词是否包含任何暴戾性语言作为子串
bool is_bad = false;
for (const string& bad : bad_words) {
// 如果找到子串,标记为违禁词并跳出循环
if (word.find(bad) != string::npos) {
is_bad = true;
break;
}
}
if (is_bad) {
count++;
}
}
cout << count << endl;
return 0;
}
这里空空如也
有帮助,赞一个