QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#355156#8104. Keyboarducup-team004#AC ✓287ms247432kbC++201.2kb2024-03-16 13:58:052024-03-16 13:58:05

Judging History

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

  • [2024-03-16 13:58:05]
  • 评测
  • 测评结果:AC
  • 用时:287ms
  • 内存:247432kb
  • [2024-03-16 13:58:05]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void rev(std::string &s) {
    int l = s.size();
    for (int i = 1; i < l; i += 2) {
        if (std::isupper(s[i])) {
            s[i] = std::tolower(s[i]);
        } else {
            s[i] = std::toupper(s[i]);
        }
    }
}

int get(char c) {
    int x;
    if (std::islower(c)) {
        x = c - 'a';
    } else {
        x = 26 + c - 'A';
    }
    return x;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::string s;
    std::cin >> s;

    int l = s.size();
    rev(s);

    std::vector nxt(l + 1, std::vector(52, l));
    for (int i = l - 1; i >= 0; i--) {
        nxt[i] = nxt[i + 1];
        int x = get(s[i]);
        nxt[i][x] = i;
    }

    int n;
    std::cin >> n;

    while (n--) {
        std::string t;
        std::cin >> t;
        rev(t);

        int i = 0;
        int ok = 1;
        for (auto c : t) {
            int x = get(c);
            i = nxt[i][x];
            if (i >= l) {
                ok = 0;
                break;
            }
            i++;
        }
        std::cout << (ok ? "YES" : "NO") << "\n";
    }

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3636kb

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: 3576kb

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: 9ms
memory: 3604kb

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: 174ms
memory: 247432kb

input:

hHHHhHHHHHHHhHhhHhhhHhhhhhhhhhHHhHHHHHHHhhHhHHHhhhhhHhhHhhHhHHHHHhHhHhhHhhHHhHHHHHHhhhhhhHhhHHhhhHHHHhhhhhhHhhhHhhhhHhHhHHHhHhHhhHHHhhHHhhHHHhhhHhHHHhhHhhhhhhHHhhHHHhHHhHHHhhHhhHHHHhHHhhhhHHhhhHHhhhhHhhhhHhhHhHHHHhhhHhhhHhHHHHhHHhHhhHHhhhHhHHhhHhhHHHHhhhhHhHhhhhhHHHHHHHHhhHhhhhHHHHhHhhhhhHHHHhhhHHhH...

output:

YES
NO

result:

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

Test #5:

score: 0
Accepted
time: 264ms
memory: 246392kb

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: 287ms
memory: 246364kb

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: 149ms
memory: 246352kb

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: 171ms
memory: 247348kb

input:

UUUuuuuuUuuuUuuUuuuuuUuuuUUuUuUuUuUUUUuuUuuUUuUuUuUuuuUuuUuuUuUUuUuUuUuUUUUUUUUuUuuuuuUUuuuUuuuUUuUuUuUUuuUUUUUUuuuUUuuUUuuUUUuUUuUuUuUuUuUuUUuUuUuuuUuuUUUuUuUuuuUUUuUuUuuUUUuUUUUuUuuUUUUuUUuuuUuUUuuUuuUuuUuUUUUUUuUuUUuUuUuUUUUuuuUuUUuUUUUuuUuuuuuUUuUuuuUuUUuuuUUuuUUUUUUuUUuuuUUUUUuUUuUuuuuUuuuuuuuu...

output:

NO
YES

result:

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

Test #9:

score: 0
Accepted
time: 283ms
memory: 246348kb

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: 275ms
memory: 246472kb

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: 114ms
memory: 246476kb

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