记录编号 |
203101 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[SYOI 2015] Asm.Def谈笑风生 |
最终得分 |
100 |
用户昵称 |
fyb |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.555 s |
提交时间 |
2015-11-02 16:23:22 |
内存使用 |
0.31 MiB |
显示代码纯文本
- #include <cstdio>
- #include <vector>
- #include <cstring>
-
- using namespace std;
-
- #define MMAX 100000
- #define LMAX 20
- #define NUM 26
-
- struct node{
- int s[NUM];
- bool v[NUM];
- };
-
- vector<node> tire;
- char ts[LMAX+1];
- node nd0;
-
- bool dfs(int pt,int tp,int lents){
- if(tp==lents-1)return tire[pt].v[ts[tp]-'a'];
- else if(!tire[pt].s[ts[tp]-'a'])return false;
- else return dfs(tire[pt].s[ts[tp]-'a'],tp+1,lents);
- }
-
- int main(){
- int m;
- int tt,tl;
- bool fndx,fnde;
- int pt;
- int i,j,k;
-
- freopen("asm_talk.in","r",stdin);
- freopen("asm_talk.out","w",stdout);
-
- scanf("%d",&m);
- tire.push_back(nd0);
- for(i=0;i<m;i++){
- scanf("%d%s",&tt,ts);
- tl=strlen(ts);
- if(tt==1){
- pt=0;
- for(j=0;ts[j+1]!='\0';j++){
- if(!tire[pt].s[ts[j]-'a']){
- tire[pt].s[ts[j]-'a']=tire.size();
- tire.push_back(nd0);
- }
- pt=tire[pt].s[ts[j]-'a'];
- }
- tire[pt].v[ts[j]-'a']=true;
- }else{
- fndx=false;
- for(j=0;j<tl;j++)
- if(ts[j]=='*'){
- fndx=true;
- fnde=false;
- for(k=0;k<NUM;k++){
- ts[j]='a'+k;
- if(dfs(0,0,tl)){
- printf("YES\n");
- fnde=true;
- break;
- }
- }
- if(!fnde)printf("NO\n");
- }
- if(!fndx)printf(dfs(0,0,tl)?"YES\n":"NO\n");
- }
- }
- return 0;
- }
-