题目链接:https://nanti.jisuanke.com/t/38232
多链表签到
#include<bits/stdc++.h>
using namespace std;#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e5+100;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){if(y==0) return x;return gcd(y,x%y);
}
/*
多链表签到
*/
int nxt[26][maxn];
char s[maxn];
int main(){scanf("%s",s);int len=strlen(s);rep(i,0,26) nxt[i][len]=-1;for(int i=len-1;i>=0;i--){rep(j,0,26) nxt[j][i]=nxt[j][i+1];nxt[s[i]-'a'][i]=i;} int q;scanf("%d",&q);while(q--){scanf("%s",s);int len=strlen(s),j=-1,flag=1;for(int i=0;i<len;i++){j=nxt[s[i]-'a'][j+1];if(j==-1) {flag=0;break;}}if(flag) puts("YES");else puts("NO");}return 0;
}