結果

問題 No.672 最長AB列
ユーザー lllllll88938494lllllll88938494
提出日時 2023-04-15 09:40:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 226 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,916 KB
実行使用メモリ 98,884 KB
最終ジャッジ日時 2024-04-19 05:39:07
合計ジャッジ時間 2,186 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,536 KB
testcase_01 AC 40 ms
55,348 KB
testcase_02 AC 41 ms
53,684 KB
testcase_03 AC 40 ms
53,928 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 40 ms
55,176 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 86 ms
98,884 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
s = input()
cnt = defaultdict(int)
cnt[0] = 1

ans = 0
t = 0
for i in range(len(s)):
    if s[i] == 'A':
        t += 1
    else:
        t -= 1
    ans += cnt[t]
    cnt[t] += 1

print(ans)
0