#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#define int long long
#define endl '\n'
#define vc vector<int>
#define vs vector<string>
using namespace std;
bool isP(string cad, string p) {
if (cad.size() < p.size()) return false;
for (int i = 0; i < p.size(); i++) {
if (cad[i] != p[i]) return false;
}
return true;
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cout.setf(ios::fixed);
cout.precision(0);
int n; cin >> n;
vs cads(n), cadp;
for(int i = 0; i < n; i++) cin >> cads[i];
string p; cin >> p;
for (string cad : cads)
if (isP(cad, p))
cadp.push_back(cad);
set<char> l;
for (string cad : cadp)
if (cad.size() > p.size())
l.insert(cad[p.size()]);
char t[4][8] = {
{'*', '*', '*', 'A', 'B', 'C', 'D', 'E'},
{'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M'},
{'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U'},
{'V', 'W', 'X', 'Y', 'Z', '*', '*', '*'}
};
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 8; j++) {
if (t[i][j] != '*' && l.find(t[i][j]) == l.end()) {
t[i][j] = '*';
}
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 8; j++) {
cout << t[i][j];
}
cout << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |