QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#646870 | #8104. Keyboard | rotcar07 | AC ✓ | 176ms | 412112kb | C++20 | 583b | 2024-10-17 09:25:37 | 2024-10-17 09:25:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=1e6+5;
int nxt[maxn][52][2];
inline int f(char c){return (c<='Z')?c-'A'+26:c-'a';}
int main(){
string s;cin>>s;int n=s.length();s=' '+s;
memset(nxt[n+1],0x3f,sizeof nxt[n+1]);
for(int i=n;i>=1;i--){
memcpy(nxt[i],nxt[i+1],sizeof nxt[i]);nxt[i][f(s[i])][i&1^1]=i;
}
int q;cin>>q;
while(q--){
string t;cin>>t;
int pos=0,w=0;
for(auto x:t){
pos++;int z=f(x);
pos=min(nxt[pos][z][w],nxt[pos][(z>25?z-26:z+26)][w^1]);
w^=1;
if(pos>n) break;
}
puts(pos>n?"NO":"YES");
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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: 0ms
memory: 3804kb
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: 32ms
memory: 3612kb
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: 145ms
memory: 411864kb
input:
hHHHhHHHHHHHhHhhHhhhHhhhhhhhhhHHhHHHHHHHhhHhHHHhhhhhHhhHhhHhHHHHHhHhHhhHhhHHhHHHHHHhhhhhhHhhHHhhhHHHHhhhhhhHhhhHhhhhHhHhHHHhHhHhhHHHhhHHhhHHHhhhHhHHHhhHhhhhhhHHhhHHHhHHhHHHhhHhhHHHHhHHhhhhHHhhhHHhhhhHhhhhHhhHhHHHHhhhHhhhHhHHHHhHHhHhhHHhhhHhHHhhHhhHHHHhhhhHhHhhhhhHHHHHHHHhhHhhhhHHHHhHhhhhhHHHHhhhHHhH...
output:
YES NO
result:
ok 2 token(s): yes count is 1, no count is 1
Test #5:
score: 0
Accepted
time: 158ms
memory: 410560kb
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: 155ms
memory: 410548kb
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: 72ms
memory: 410624kb
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: 151ms
memory: 412112kb
input:
UUUuuuuuUuuuUuuUuuuuuUuuuUUuUuUuUuUUUUuuUuuUUuUuUuUuuuUuuUuuUuUUuUuUuUuUUUUUUUUuUuuuuuUUuuuUuuuUUuUuUuUUuuUUUUUUuuuUUuuUUuuUUUuUUuUuUuUuUuUuUUuUuUuuuUuuUUUuUuUuuuUUUuUuUuuUUUuUUUUuUuuUUUUuUUuuuUuUUuuUuuUuuUuUUUUUUuUuUUuUuUuUUUUuuuUuUUuUUUUuuUuuuuuUUuUuuuUuUUuuuUUuuUUUUUUuUUuuuUUUUUuUUuUuuuuUuuuuuuuu...
output:
NO YES
result:
ok 2 token(s): yes count is 1, no count is 1
Test #9:
score: 0
Accepted
time: 176ms
memory: 410420kb
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: 175ms
memory: 410668kb
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: 95ms
memory: 410580kb
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