比赛 |
20241021 |
评测结果 |
AAAAAAAAAAAAAA |
题目名称 |
子序列 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
0.078 s |
代码语言 |
C++ |
内存使用 |
4.86 MiB |
提交时间 |
2024-10-21 08:37:00 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define in inline
#define se second
#define mp make_pair
#define pb push_back
const int N = 1e5+10;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
char c[N],ch[110];
int n,m;
int nx[N][26];
int main(){
freopen("subsequence.in","r",stdin);
freopen("subsequence.out","w",stdout);
scanf("%s",c + 1);
n = strlen(c + 1);
for(int i = 0;i < 26;i++)nx[n][i] = n + 1;
for(int i = n-1;i >= 0;i--){
for(int j = 0;j < 26;j++)nx[i][j] = nx[i+1][j];
nx[i][c[i+1] - 'a'] = i + 1;
}
m = read();
for(int i = 1;i <= m;i++){
scanf("%s",ch + 1);
int len = strlen(ch + 1);
int now = 0,j = 0;
for(j = 1;j <= len;j++){
if(nx[now][ch[j] - 'a'] <= n)now = nx[now][ch[j] - 'a'];
else break;
}
if(j <= len)printf("No\n");
else printf("Yes\n");
}
return 0;
}