QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#335961#8104. Keyboarducup-team1209#WA 0ms3632kbC++201.3kb2024-02-24 10:28:512024-02-24 10:28:52

Judging History

你现在查看的是最新测评结果

  • [2024-02-24 10:28:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-02-24 10:28:51]
  • 提交

answer

#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;

cs int N = 1e6 + 5; 
string S, T; 
int n; 
int nxt[N][52];
int id(char c) {
    return ('a' <= c && c <= 'z') ? c - 'a' : c - 'A' + 26; 
}
int main() {
    #ifdef zqj
    freopen("1.in","r",stdin);
    #endif
    ios :: sync_with_stdio(0), cin.tie(0);
    cin >> S; 
    cin >> n;
    int m = S.length();
    for(int i = 0; i < m; i++)
        if(i & 1 ^ 1){
            if('a' <= S[i] && S[i] <= 'z') S[i] = S[i] - 'a' + 'A';
            else S[i] = S[i] - 'A' + 'a';
        }
    vector <int> c(52, m);
    for(int i = m - 1; i >= 0; i--){
        int t = id(S[i]);
        c[t] = i;  
        for(int j = 0; j < 52; j++) nxt[i][j] = c[j];
    }
    for(int i = 1; i <= n; i++) {
        cin >> T;
        int k = T.length();
        for(int i = 0; i < k; i++)
            if(i & 1 ^ 1){
                if('a' <= T[i] && T[i] <= 'z') T[i] = T[i] - 'a' + 'A';
                else T[i] = T[i] - 'A' + 'a';
            }
        int cur = 0; 
        for(int i = 0;i  < k; i++) { 
            // cout << T[i] <<' ' << id(T[i]) << endl;
            cur = nxt[cur][id(T[i])];
            if(cur >= m) break;
        }
        if(cur < m) {
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

PTaak
4
PA
tak
ptak
nie

output:

YES
YES
NO
NO

result:

ok 4 token(s): yes count is 2, no count is 2

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3632kb

input:

X
5
XX
Xx
X
x
a

output:

NO
YES
YES
NO
NO

result:

wrong answer expected NO, found YES [2nd token]