序列自动机
模板
查找主串中的子序列
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int nxt[maxn][26];
char s[maxn], t[maxn];
int main() {
scanf("%s", s + 1);
int len = strlen(s + 1);
for (int i = len; i >= 1; i--) {
for (int j = 0; j < 26; j++) {
nxt[i - 1][j] = nxt[i][j];
}
nxt[i - 1][s[i] - 'a'] = i;
}
int q;
scanf("%d", &q);
while(q--) {
scanf("%s", t);
int len1 = strlen(t);
int f = 0;
for (int i = 0, u = 0; i < len1; i++) {
int v = t[i] - 'a';
u = nxt[u][v];
if(u==0) {
f = 1;
break;
}
}
if(f) {
printf("NO
");
}
else
printf("YES
");
}
}