結果
問題 | No.672 最長AB列 |
ユーザー | yn |
提出日時 | 2019-01-26 16:19:48 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 755 bytes |
コンパイル時間 | 970 ms |
コンパイル使用メモリ | 87,228 KB |
実行使用メモリ | 81,316 KB |
最終ジャッジ日時 | 2023-10-14 10:16:53 |
合計ジャッジ時間 | 5,872 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,724 KB |
testcase_01 | AC | 71 ms
71,300 KB |
testcase_02 | AC | 72 ms
71,468 KB |
testcase_03 | AC | 72 ms
71,376 KB |
testcase_04 | AC | 71 ms
71,236 KB |
testcase_05 | AC | 74 ms
71,348 KB |
testcase_06 | AC | 70 ms
71,496 KB |
testcase_07 | AC | 72 ms
71,428 KB |
testcase_08 | AC | 70 ms
71,500 KB |
testcase_09 | AC | 73 ms
71,928 KB |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
ソースコード
s = input() if s.count("A") == 0 or s.count("B") == 0: print(0) exit() l = 0 r = 2 len_s = len(s) while l < len_s and r <= len_s: if s[l:r].count("A") != s[l:r].count("B"): l += 1 r += 1 continue if l - 2 >= 0: if s[l - 2:l].count("A") == 1 and \ s[l - 2:l].count("B") == 1: l -= 2 continue if l - 1 >= 0 and r < len_s: if (s[l - 1] + s[r]).count("A") == 1 and \ (s[l - 1] + s[r]).count("B") == 1: l -= 1 r += 1 continue if r + 2 <= len_s: if s[r:r + 2].count("A") == 1 and \ s[r:r + 2].count("B") == 1: r += 2 continue l += 1 r += 1 print(r - l)