比赛 20241021 评测结果 AAAAAAAAAAAAAA
题目名称 子序列 最终得分 100
用户昵称 darkMoon 运行时间 0.096 s
代码语言 C++ 内存使用 6.71 MiB
提交时间 2024-10-21 08:43:12
显示代码纯文本
#include<bits/stdc++.h>
#define int long long
using namespace std;
auto IN = freopen("subsequence.in", "r", stdin);
auto OUT = freopen("subsequence.out", "w", stdout);
auto mread = [](){int x;scanf("%lld", &x);return x;};
const int N = 1e5 + 5;
char s[N], b[55];
int to[N][30], n;
signed main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    int la[30];
    for(int i = 0; i < 26; i ++){
        la[i] = n + 1;
    }
    for(int i = n; i >= 1; i --){
        la[s[i] - 'a'] = i;
        for(int j = 0; j < 26; j ++){
            to[i][j] = la[j];
        }
    }
    for(int j = 0; j < 26; j ++){
        to[0][j] = la[j];
    }
    int t = mread();
    while(t --){
        scanf("%s", b + 1);
        int m = strlen(b + 1);
        int x = 0;
        for(int i = 1; i <= m; i ++){
            x = to[x][b[i] - 'a'];
            if(x == n + 1){
                printf("No\n");
                break;
            }
        }
        if(x <= n){
            printf("Yes\n");
        }
    }
    return 0;
}