結果

問題 No.2240 WAC
ユーザー neterukunneterukun
提出日時 2023-03-10 21:57:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 1,405 ms
コンパイル使用メモリ 81,516 KB
実行使用メモリ 120,316 KB
最終ジャッジ日時 2023-10-18 07:43:15
合計ジャッジ時間 5,729 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,372 KB
testcase_01 AC 39 ms
53,372 KB
testcase_02 AC 38 ms
53,372 KB
testcase_03 AC 40 ms
53,372 KB
testcase_04 AC 39 ms
53,372 KB
testcase_05 AC 39 ms
53,372 KB
testcase_06 AC 39 ms
53,372 KB
testcase_07 AC 38 ms
53,372 KB
testcase_08 AC 38 ms
53,372 KB
testcase_09 AC 38 ms
53,372 KB
testcase_10 AC 125 ms
120,316 KB
testcase_11 AC 112 ms
113,980 KB
testcase_12 AC 116 ms
113,980 KB
testcase_13 AC 51 ms
67,384 KB
testcase_14 AC 60 ms
71,672 KB
testcase_15 AC 58 ms
74,352 KB
testcase_16 AC 91 ms
96,480 KB
testcase_17 AC 96 ms
97,772 KB
testcase_18 AC 64 ms
74,920 KB
testcase_19 AC 61 ms
69,952 KB
testcase_20 AC 60 ms
74,744 KB
testcase_21 AC 91 ms
96,956 KB
testcase_22 AC 52 ms
69,364 KB
testcase_23 AC 51 ms
67,388 KB
testcase_24 AC 59 ms
74,276 KB
testcase_25 AC 105 ms
101,572 KB
testcase_26 AC 68 ms
82,528 KB
testcase_27 AC 64 ms
74,876 KB
testcase_28 AC 51 ms
66,380 KB
testcase_29 AC 46 ms
60,488 KB
testcase_30 AC 53 ms
69,380 KB
testcase_31 AC 117 ms
110,524 KB
testcase_32 AC 64 ms
76,164 KB
testcase_33 AC 98 ms
99,448 KB
testcase_34 AC 107 ms
106,180 KB
testcase_35 AC 56 ms
69,204 KB
testcase_36 AC 105 ms
104,356 KB
testcase_37 AC 61 ms
76,444 KB
testcase_38 AC 50 ms
66,420 KB
testcase_39 AC 65 ms
78,568 KB
testcase_40 AC 89 ms
95,064 KB
testcase_41 AC 58 ms
72,936 KB
testcase_42 AC 57 ms
72,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
s = input()


used = [False] * ((n + m) * 2)

posA = []
for i in range((n + m) * 2):
    if s[i] == "A":
        posA.append(i)

posA = posA[::-1]
for i in range((n + m) * 2):
    if s[i] == "C":
        j = posA.pop()
        if j < i:
            used[i] = True
            used[j] = True
        else:
            print("No")
            exit()

t = []
for i in range((n + m) * 2):
    if not used[i]:
        t.append(s[i])

stack = []
for char in t:
    if char == "A" and stack and stack[-1] == "W":
        stack.pop()
    else:
        stack.append(char)
if stack:
    print("No")
else:
    print("Yes")
0