显示代码纯文本
#include <iostream>
#include <fstream>
#include <set>
#include <string>
using namespace std;
fstream fin, fout;
set<string> s;
int n, t;
string ts;
void find(string &ts) {
int tl = ts.length();
for(int i = 0; i < tl; i++)
if(ts[i] == '*') {
for(int j = 'a'; j <= 'z'; j++) {
ts[i] = j;
//cout << "ts=" << ts << endl;
if(s.count(ts)) { fout << "YES" << endl; return; }
}
fout << "NO" << endl; return;
}
if(s.count(ts)) { fout << "YES" << endl; return; }
else { fout << "NO" << endl; return; }
}
int main() {
fin.open("asm_talk.in", ios::in);
fout.open("asm_talk.out", ios::out);
fin >> n;
for(int i = 0; i < n; i++) {
fin >> t >> ts;
if(t == 1) s.insert(ts);
else find(ts);
}
return 0;
}