QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#364654#8104. Keyboardckiseki#WA 7ms3832kbC++201.7kb2024-03-24 15:51:372024-03-24 15:51:38

Judging History

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

  • [2024-03-24 15:51:38]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3832kb
  • [2024-03-24 15:51:37]
  • 提交

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 = (p + 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: 0ms
memory: 3832kb

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

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: -100
Wrong Answer
time: 7ms
memory: 3496kb

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
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

wrong answer expected YES, found NO [5th token]