RT, CSP-J考试时两个作弊的,想严查一下, 只有马蜂不同
// 一号同学
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
using ll = long long;
const int kMaxN = 11, kInf = (((1 << 30) - 1) << 1) + 1;
int n;
string s[kMaxN], qwe;
int main() {
freopen("aprillie.in", "r", stdin);
freopen("aprillie.out", "w", stdout);
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
for (cin >> t; t; -- t) {
cin >> n;
for (int i = 1; i <= n; ++ i) {
cin >> s[i];
}
cin >> qwe, qwe = ' ' + qwe + ' ';
for (int i = 1; i < qwe.size() - 1; ++ i) {
for (int j = 1; j <= n; ++ j) {
if (i - int(s[j].size()) < 0) {
continue;
}
(qwe.substr(i - int(s[j].size()) + 1, int(s[j].size())) == s[j]? qwe[i] = '*' : 114514);
}
}
cout << qwe.substr(1) << '\n';
}
return 0;
}
// 二号同学
#include<bits/stdc++.h>
using namespace std;
const int Kmaxn = 15;
int t, n;
string s, s2[Kmaxn];
int main(){
freopen("aprillie.in", "r", stdin);
freopen("aprillie.out", "w", stdout);
cin >> t;
while(t--){
cin >> n;
for(int i = 1 ; i <= n ; i++){
cin >> s2[i];
}
cin >> s;
int len = s.size();
s = " " + s + " ";
for(int i = 1 ; i <= len ; i++){
for(int j = 1 ; j <= n ; j++){
if(i < int(s2[j].size())) continue;
if(s.substr(i - int(s2[j].size()) + 1, int(s2[j].size())) == s2[j]) s[i] = '*';
}
}
cout << s.substr(1, len) <<"\n";
}
return 0;
}