比赛 |
“Asm.Def战记之太平洋”杯 |
评测结果 |
C |
题目名称 |
Asm.Def谈笑风生 |
最终得分 |
0 |
用户昵称 |
StanTia |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2015-11-02 11:06:42 |
显示代码纯文本
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
vector<string> Code; //通配符之前/无通配符
void New_Code()
{
string input;
cin>>input;
Code.push_back(input);
}
void Find()
{
string for_find;
cin>>for_find;
int index = for_find.find('*');
if(index == -1) // No *
{
if(find(Code.begin(),Code.end(),for_find) == Code.end())
{
cout<<"NO"<<endl;
}else{
cout<<"YES"<<endl;
}
return;
}
string front = for_find.substr(0,index);
string end = for_find.substr(index + 1,for_find.length()-1);
for(vector<string>::iterator iter = Code.begin();iter != Code.end();iter++)
{
if(iter->length() != for_find.length())
{
continue;
}
string str = *iter;
str.erase(index,1);
if(str == front + end)
{
cout<<"YES"<<endl;
return;
}
}
cout<<"NO"<<endl;
}
int main()
{
freopen("asm_talk.in","r",stdin);
freopen("asm_talk.out","w",stdout);
int key_num,key;
cin>>key_num;
for(int i = 0;i < key_num; i++)
{
cin>>key;
if(key == 1)
{
New_Code();
}else{
Find();
}
}
return 0;
}