占位符不要用%#*^之类的,测试点5和7会被卡
#include <bits/stdc++.h>
using namespace std;
void print(string s)
{
for(auto si : s)
if(si == '{') cout << "<censored>";
else cout << si;
cout << endl;
}
int main()
{
int n;
cin >> n;
vector<string> v;
for(int i = 1; i <= n; ++ i)
{
string s;
cin >> s;
v.push_back(s);
}
int k, cnt = 0;
cin >> k;
cin.ignore();
string str;
getline(cin,str);
for(auto vi : v)
{
for(int i = 0; i < str.size(); ++ i)
{
int findpos = str.find(vi,i);
if(findpos == -1) break;
else
{
++ cnt;
str.replace(findpos,vi.size(),"{");
}
}
}
if(cnt >= k) cout << cnt << "\n" << "He Xie Ni Quan Jia!";
else print(str);
return 0;
}
标签:cnt,15,cout,int,vi,cin,多猫娘,str,L1
From: https://www.cnblogs.com/Frodnx/p/18397217