QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#364715 | #8104. Keyboard | ckiseki# | AC ✓ | 128ms | 411532kb | C++20 | 1.6kb | 2024-03-24 16:12:34 | 2024-03-24 16:12:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
using namespace experimental;
copy(L, R, make_ostream_joiner(cerr, ", "));
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
constexpr int N = 1'000'000 + 5;
int np[N][52][2];
int Char2Int(char c) {
if (isupper(c)) {
return 2 * (c - 'A') + 1;
}
return 2 * (c - 'a');
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
string s;
cin >> s;
const int n = int(s.size());
int cur[52][2];
for (int i = 0; i < 52; ++i)
for (int j = 0; j < 2; ++j)
cur[i][j] = n + 1;
for (int i = n; i >= 0; --i) {
for (int j = 0; j < 52; ++j)
for (int k = 0; k < 2; ++k)
np[i][j][k] = cur[j][k];
if (i)
cur[Char2Int(s[i - 1])][i & 1] = i;
}
int q;
cin >> q;
while (q--) {
string qi;
cin >> qi;
bool ok = true;
int swp = 1;
int p = 0;
for (auto c : qi) {
int o = (swp) & 1;
int x = Char2Int(c);
int nxt = min(np[p][x][o], np[p][x ^ 1][o ^ 1]);
if (nxt == n + 1) {
ok = false;
break;
}
swp ^= 1;
p = nxt;
}
cout << (ok ? "YES" : "NO") << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
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: 3544kb
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: 3548kb
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: 100ms
memory: 411532kb
input:
hHHHhHHHHHHHhHhhHhhhHhhhhhhhhhHHhHHHHHHHhhHhHHHhhhhhHhhHhhHhHHHHHhHhHhhHhhHHhHHHHHHhhhhhhHhhHHhhhHHHHhhhhhhHhhhHhhhhHhHhHHHhHhHhhHHHhhHHhhHHHhhhHhHHHhhHhhhhhhHHhhHHHhHHhHHHhhHhhHHHHhHHhhhhHHhhhHHhhhhHhhhhHhhHhHHHHhhhHhhhHhHHHHhHHhHhhHHhhhHhHHhhHhhHHHHhhhhHhHhhhhhHHHHHHHHhhHhhhhHHHHhHhhhhhHHHHhhhHHhH...
output:
YES NO
result:
ok 2 token(s): yes count is 1, no count is 1
Test #5:
score: 0
Accepted
time: 107ms
memory: 410524kb
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: 110ms
memory: 410392kb
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: 68ms
memory: 410508kb
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: 123ms
memory: 411460kb
input:
UUUuuuuuUuuuUuuUuuuuuUuuuUUuUuUuUuUUUUuuUuuUUuUuUuUuuuUuuUuuUuUUuUuUuUuUUUUUUUUuUuuuuuUUuuuUuuuUUuUuUuUUuuUUUUUUuuuUUuuUUuuUUUuUUuUuUuUuUuUuUUuUuUuuuUuuUUUuUuUuuuUUUuUuUuuUUUuUUUUuUuuUUUUuUUuuuUuUUuuUuuUuuUuUUUUUUuUuUUuUuUuUUUUuuuUuUUuUUUUuuUuuuuuUUuUuuuUuUUuuuUUuuUUUUUUuUUuuuUUUUUuUUuUuuuuUuuuuuuuu...
output:
NO YES
result:
ok 2 token(s): yes count is 1, no count is 1
Test #9:
score: 0
Accepted
time: 128ms
memory: 410576kb
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: 123ms
memory: 410620kb
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: 52ms
memory: 410528kb
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