結果

問題 No.2240 WAC
ユーザー titan23titan23
提出日時 2023-03-11 11:11:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,153 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 102,672 KB
最終ジャッジ日時 2023-10-18 09:47:08
合計ジャッジ時間 6,423 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
68,244 KB
testcase_01 AC 63 ms
68,244 KB
testcase_02 AC 64 ms
68,244 KB
testcase_03 AC 63 ms
68,244 KB
testcase_04 AC 64 ms
68,244 KB
testcase_05 AC 66 ms
68,244 KB
testcase_06 AC 64 ms
68,244 KB
testcase_07 AC 65 ms
68,244 KB
testcase_08 AC 65 ms
68,244 KB
testcase_09 AC 62 ms
68,244 KB
testcase_10 AC 124 ms
102,048 KB
testcase_11 WA -
testcase_12 AC 115 ms
98,892 KB
testcase_13 AC 95 ms
85,732 KB
testcase_14 AC 90 ms
79,296 KB
testcase_15 AC 108 ms
96,548 KB
testcase_16 WA -
testcase_17 AC 104 ms
92,292 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 109 ms
98,604 KB
testcase_21 WA -
testcase_22 AC 93 ms
88,364 KB
testcase_23 AC 95 ms
85,352 KB
testcase_24 AC 109 ms
97,020 KB
testcase_25 WA -
testcase_26 AC 93 ms
85,020 KB
testcase_27 AC 88 ms
80,312 KB
testcase_28 AC 92 ms
83,608 KB
testcase_29 AC 86 ms
78,516 KB
testcase_30 AC 99 ms
88,472 KB
testcase_31 AC 116 ms
102,668 KB
testcase_32 WA -
testcase_33 AC 102 ms
91,604 KB
testcase_34 AC 105 ms
96,240 KB
testcase_35 AC 86 ms
77,960 KB
testcase_36 WA -
testcase_37 AC 115 ms
101,500 KB
testcase_38 AC 93 ms
85,476 KB
testcase_39 AC 118 ms
100,552 KB
testcase_40 AC 98 ms
89,288 KB
testcase_41 AC 104 ms
93,064 KB
testcase_42 AC 105 ms
92,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()

from typing import Iterable, List, Any

class Deque:

  # コンセプト: ランダムアクセスO(1)でできるDeque
  # 
  # pop/popleft: O(1)
  # append/appendleft: O(1)
  # tolist: O(N)
  # getitem/setitem: O(1)
  # contains: O(N)
  # 
  # その他
  # rotate(実装予定なし)
  # 

  def __init__(self, a: Iterable[Any]=[]):
    self.front = []
    self.back = list(a)

  def _rebuild(self) -> None:
    new = self.front[::-1] + self.back
    self.front = new[:len(new)//2][::-1]
    self.back = new[len(new)//2:]

  def pop(self) -> Any:
    if not self.back:
      self._rebuild()
    return self.back.pop() if self.back else self.front.pop()

  def popleft(self) -> Any:
    if not self.front:
      self._rebuild()
    return self.front.pop() if self.front else self.back.pop()

  def append(self, v: Any) -> None:
    self.back.append(v)

  def appendleft(self, v: Any) -> None:
    self.front.append(v)

  def tolist(self) -> List[Any]:
    return self.front[::-1] + self.back

  def __getitem__(self, k: int) -> Any:
    if k < 0: k += len(self)
    return self.front[len(self.front)-k-1] if k < len(self.front) else self.back[k-len(self.front)]

  def __setitem__(self, k: int, v: Any):
    if k < 0: k += len(self)
    if k < len(self.front):
      self.front[len(self.front)-k-1] = v
    else:
      self.back[k-len(self.front)] = v

  def __bool__(self):
    return self.front or self.back

  def __len__(self):
    return len(self.front) + len(self.back)

  def __contains__(self, v):
    return (v in self.front) or (v in self.back)

  def __str__(self):
    return '[' + ', '.join(map(str, self.tolist())) + ']'

  def __repr__(self):
    return f'Deque({self})'

#  -----------------------  #

n, m = map(int, input().split())
s = input()
W, A, C = Deque(), Deque(), Deque()
for i, c in enumerate(s):
  if c == 'W':
    W.append(i)
  elif c == 'A':
    A.append(i)
  else:
    C.append(i)
for _ in range(n):
  w = W.popleft()
  a = A.pop()
  if w > a:
    exit(print('No'))
for _ in range(m):
  a = A.pop()
  c = C.pop()
  if a > c:
    exit(print('No'))
print('Yes')
0