結果

問題 No.2240 WAC
コンテスト
ユーザー 学ぶマン
提出日時 2025-10-20 17:02:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 453 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 125,456 KB
最終ジャッジ日時 2025-10-20 17:02:40
合計ジャッジ時間 5,535 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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