結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2023-04-15 09:40:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 226 bytes |
コンパイル時間 | 902 ms |
コンパイル使用メモリ | 82,340 KB |
実行使用メモリ | 97,052 KB |
最終ジャッジ日時 | 2024-10-10 22:16:11 |
合計ジャッジ時間 | 2,679 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 13 |
ソースコード
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)