QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#377309 | #8104. Keyboard | SolitaryDream# | AC ✓ | 913ms | 52072kb | C++17 | 1.2kb | 2024-04-05 12:12:00 | 2024-04-05 12:12:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)
set<int> a[52][2];
int trans(char c) {
if(c>='a' && c<='z') return c-'a';
else return c-'A'+26;
}
int rev(int x) {
if(x<26) return x+26;
else return x-26;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
int n=s.size();
FOR(i,0,n-1) {
// cerr << trans(s[i]) << '\n';
a[trans(s[i])][i&1].insert(i);
}
int T;
cin >> T;
while(T--) {
string t;
cin >> t;
int p=0,w=0,ans=1;
for(auto c: t) {
int v=trans(c);
if(w) v=rev(v);
int q=n;
auto it=a[v][0].lower_bound(p);
if(it!=a[v][0].end()) {
q=min(q,*it);
}
it=a[rev(v)][1].lower_bound(p);
if(it!=a[rev(v)][1].end()) {
q=min(q,*it);
}
if(q==n) {
ans=0;
break;
}
// cerr << q << endl;
p=q+1;
w^=1;
}
cout << (ans?"YES":"NO") << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
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: 3528kb
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: 8ms
memory: 3564kb
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: 272ms
memory: 52072kb
input:
hHHHhHHHHHHHhHhhHhhhHhhhhhhhhhHHhHHHHHHHhhHhHHHhhhhhHhhHhhHhHHHHHhHhHhhHhhHHhHHHHHHhhhhhhHhhHHhhhHHHHhhhhhhHhhhHhhhhHhHhHHHhHhHhhHHHhhHHhhHHHhhhHhHHHhhHhhhhhhHHhhHHHhHHhHHHhhHhhHHHHhHHhhhhHHhhhHHhhhhHhhhhHhhHhHHHHhhhHhhhHhHHHHhHHhHhhHHhhhHhHHhhHhhHHHHhhhhHhHhhhhhHHHHHHHHhhHhhhhHHHHhHhhhhhHHHHhhhHHhH...
output:
YES NO
result:
ok 2 token(s): yes count is 1, no count is 1
Test #5:
score: 0
Accepted
time: 506ms
memory: 51168kb
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: 756ms
memory: 51180kb
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: 350ms
memory: 50840kb
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: 332ms
memory: 52056kb
input:
UUUuuuuuUuuuUuuUuuuuuUuuuUUuUuUuUuUUUUuuUuuUUuUuUuUuuuUuuUuuUuUUuUuUuUuUUUUUUUUuUuuuuuUUuuuUuuuUUuUuUuUUuuUUUUUUuuuUUuuUUuuUUUuUUuUuUuUuUuUuUUuUuUuuuUuuUUUuUuUuuuUUUuUuUuuUUUuUUUUuUuuUUUUuUUuuuUuUUuuUuuUuuUuUUUUUUuUuUUuUuUuUUUUuuuUuUUuUUUUuuUuuuuuUUuUuuuUuUUuuuUUuuUUUUUUuUUuuuUUUUUuUUuUuuuuUuuuuuuuu...
output:
NO YES
result:
ok 2 token(s): yes count is 1, no count is 1
Test #9:
score: 0
Accepted
time: 595ms
memory: 51140kb
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: 913ms
memory: 51192kb
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: 345ms
memory: 50900kb
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