QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#335965#8104. Keyboarducup-team1209#AC ✓119ms208848kbC++201.4kb2024-02-24 10:32:452024-02-24 10:32:46

Judging History

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

  • [2024-02-24 10:32:46]
  • 评测
  • 测评结果:AC
  • 用时:119ms
  • 内存:208848kb
  • [2024-02-24 10:32:45]
  • 提交

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 = -1;
        int FLAG = 0; 
        for(int i = 0;i  < k; i++) { 
            if(cur >= m - 1) {
                FLAG = 1; 
                break;
            }
            cur = nxt[cur + 1][id(T[i])];
        }
        if(!FLAG && cur < m) {
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
}

詳細信息

Test #1:

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

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: 0
Accepted
time: 1ms
memory: 3536kb

input:

X
5
XX
Xx
X
x
a

output:

NO
NO
YES
NO
NO

result:

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

Test #3:

score: 0
Accepted
time: 6ms
memory: 3620kb

input:

pPjjJjpjJpJpJPJ
65540
PJjJJPJ
PJJJpjpjpj
JjP
PJjjjPjPJjP
pPJjPj
ppjjjJpjJp
jjpjJp
ppjjJPJPP
pJJPpjJpJ
pPJpJ
ppjJJPpjP
pJjjppJ
pJpjpjP
pPjjJPJjPj
PJjPJp
pjJjJpJj
pJJjJPJpPjp
jJpJJjpp
ppjjpPJp
JPJjJj
pJJpPjpj
PjjPPj
jPjjpj
pPJjPp
pjjPjjJ
pjpjpj
jjJPPj
PJpjJp
pJJj
pPJj
pjJpJppj
pJJPPP
ppjjjJpp
pJJPJjP
...

output:

NO
NO
YES
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
YES
NO
YES
NO
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
NO
YES
NO
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
YES
NO
YES...

result:

ok 65540 token(s): yes count is 35746, no count is 29794

Test #4:

score: 0
Accepted
time: 79ms
memory: 208848kb

input:

hHHHhHHHHHHHhHhhHhhhHhhhhhhhhhHHhHHHHHHHhhHhHHHhhhhhHhhHhhHhHHHHHhHhHhhHhhHHhHHHHHHhhhhhhHhhHHhhhHHHHhhhhhhHhhhHhhhhHhHhHHHhHhHhhHHHhhHHhhHHHhhhHhHHHhhHhhhhhhHHhhHHHhHHhHHHhhHhhHHHHhHHhhhhHHhhhHHhhhhHhhhhHhhHhHHHHhhhHhhhHhHHHHhHHhHhhHHhhhHhHHhhHhhHHHHhhhhHhHhhhhhHHHHHHHHhhHhhhhHHHHhHhhhhhHHHHhhhHHhH...

output:

YES
NO

result:

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

Test #5:

score: 0
Accepted
time: 112ms
memory: 207380kb

input:

UqRQSKQAJjajWjqoJbojKaAaUjsJWjBBuuRawASBSoAsAoKbUjKBWQABWOaoOWKrssOuQOuKQAujquROQkUaSkooOQaObWsOASASkWuBrwjqrrQsswJsuRwOAJBQQKSaqWabjQJabQKWqoOUKSOoOuaOjrAjUoBSqbkqbkJJajkkjSOSbuUrkkUJkoKqUkWbUrASARjJOKSRwuqSJAKbBUBKWJuqRoSJSqJJORquaSuaWaSOSQOBrBrArokJJJBruOOwaouSSsqQRUUubqbAOjjRJOQBBWQOqrkuorjssubs...

output:

YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO

result:

ok 25 token(s): yes count is 16, no count is 9

Test #6:

score: 0
Accepted
time: 119ms
memory: 207392kb

input:

oicyhJHPhfthbVRZiYZNXuVFpWywYcDdTlSdNSvBvBehoELcgROsALFJmmHZbBpFJRzNNjlMxmmjkMNsUzuNyHUChZZOWTAhMmEkIRODiLrZGCpEiCOLBlIAseTWlbHmcgPopfuVnddGuCpofDZPrbeUTusmlZTTpunqDOiBDyvrSXcLJMDInJZTngIIiIrqBONCfVDeHtNvbYVDUPuMdtDdxYAByRGjoUlrhndAlmXLaXPffJvlWJselredCXcEUPQDjoXABRctpnaxmGqPtpsAFwZauxrzGphAMptmsmEK...

output:

NO
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
YES
NO
YES
YES
NO
YES
YES
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 68 token(s): yes count is 44, no count is 24

Test #7:

score: 0
Accepted
time: 45ms
memory: 207308kb

input:

HoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHHHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHuHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHHHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHqHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHHHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHuHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHHHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHPHoHgHoHRHoHgHoHQHoHgHoHRHoHgHoHHHoHgHoHRHoHg...

output:

NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO
YES
NO
NO
YES
NO
YES
YES
YES
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
YES
YES
NO
NO
YES
NO
NO
NO
NO
YES
NO
YES
YE...

result:

ok 10532 token(s): yes count is 4165, no count is 6367

Test #8:

score: 0
Accepted
time: 97ms
memory: 208180kb

input:

UUUuuuuuUuuuUuuUuuuuuUuuuUUuUuUuUuUUUUuuUuuUUuUuUuUuuuUuuUuuUuUUuUuUuUuUUUUUUUUuUuuuuuUUuuuUuuuUUuUuUuUUuuUUUUUUuuuUUuuUUuuUUUuUUuUuUuUuUuUuUUuUuUuuuUuuUUUuUuUuuuUUUuUuUuuUUUuUUUUuUuuUUUUuUUuuuUuUUuuUuuUuuUuUUUUUUuUuUUuUuUuUUUUuuuUuUUuUUUUuuUuuuuuUUuUuuuUuUUuuuUUuuUUUUUUuUUuuuUUUUUuUUuUuuuuUuuuuuuuu...

output:

NO
YES

result:

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

Test #9:

score: 0
Accepted
time: 110ms
memory: 207352kb

input:

NBborwTNQQWrBRTWOoGrOHGAQooaHqhAtooWgTOtrnQoTNNgHghOWBRnWhTgbbATnOnoGObGWhGBQARHAbTAoRQoTNAaRgGognwRwRQTqNWGtGqoWhNqTthtwaTWTOROaTQRGAotqggaNGaoWrWnqToonnrNNNGANBaRbBWaAQrNboaQwwRWwowRGwhGWBhoqThqqhTGroHhWrRTtbTgqqWNTNgAHtarwwhhBHwBaGwQhbqbHGOohBqhraNABwBNRWbnHnThOOBWaghQHHNBntbQotnOrraOORRwhttBoOgT...

output:

YES
YES
YES
YES
NO
NO
NO
NO
YES
NO
YES
NO
YES
YES
NO
NO
NO
NO
YES
YES

result:

ok 20 token(s): yes count is 10, no count is 10

Test #10:

score: 0
Accepted
time: 113ms
memory: 207516kb

input:

qoLGpdxjjtGLLiJjoQOeeQxKBnAxBQCQhyoaItgNeLDzoTSTukpAqncwIczidQPmhuNVjYXjPKSlTJZfiQvoUnunwHHMGatSIfwDoNlGVTLltVsmaElJODukAylQGrmMORRfJrpfnFKKWkHdPDTJnrumNWztVSfvUINrXDAjsQwbrWMzjSGuzUDGalHQcpSbNEcKogWxUjPXHpScVhFYdDfSbkQKmCXyxjlSZtsMwDPPzIgasMMCkSjYFfCvHeJGXfyttHWGPhYchKjmsdLIEOEgHBWHYYYjjmphSlnjjvPF...

output:

YES
NO
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
NO
YES
NO
YES
NO
YES
YES
NO
YES
NO
YES
YES
YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
NO
YES
NO
YES
YES
NO
YES
YES
YES
NO
NO
YES

result:

ok 52 token(s): yes count is 30, no count is 22

Test #11:

score: 0
Accepted
time: 40ms
memory: 207356kb

input:

ATAvATAQATAvATAwATAvATAQATAvATAyATAvATAQATAvATAwATAvATAQATAvATAjATAvATAQATAvATAwATAvATAQATAvATAyATAvATAQATAvATAwATAvATAQATAvATAoATAvATAQATAvATAwATAvATAQATAvATAyATAvATAQATAvATAwATAvATAQATAvATAjATAvATAQATAvATAwATAvATAQATAvATAyATAvATAQATAvATAwATAvATAQATAvATAtATAvATAQATAvATAwATAvATAQATAvATAyATAvATAQATAv...

output:

YES
YES
YES
NO
YES
NO
YES
NO
YES
YES
NO
YES
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
YES
YES
NO
YES
NO
YES
NO
YES
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
YES
NO
NO...

result:

ok 114624 token(s): yes count is 53207, no count is 61417