結果

問題 No.2240 WAC
コンテスト
ユーザー koheijkt
提出日時 2025-10-20 17:02:34
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 453 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 95,856 KB
実行使用メモリ 133,052 KB
最終ジャッジ日時 2026-07-15 19:35:46
合計ジャッジ時間 6,092 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys, math
sys.set_int_max_str_digits(0)

N, M = map(int, input().split())
S = input()

# AC を貪欲に消す
stack = []

for s in S:
    if stack and stack[-1] == 'A' and s == 'C':
        stack.pop()
    else:
        stack.append(s)

# WA を貪欲に消す
stack2 = []
for s in stack:
    if stack2 and stack2[-1] == 'W' and s == 'A':
        stack2.pop()
    else:
        stack2.append(s)

if stack2:
    print('No')
else:
    print('Yes')
0