結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
yn
|
| 提出日時 | 2019-01-26 16:17:56 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,007 bytes |
| コンパイル時間 | 121 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 17,692 KB |
| 最終ジャッジ日時 | 2024-09-16 05:12:04 |
| 合計ジャッジ時間 | 4,803 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 2 WA * 5 OLE * 1 -- * 8 |
ソースコード
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
print(s[l:r], s[l:r].count("A"), s[l:r].count("B"))
continue
if l - 2 >= 0:
if s[l - 2:l].count("A") == 1 and \
s[l - 2:l].count("B") == 1:
l -= 2
print(s[l:r], s[l:r].count("A"), s[l:r].count("B"))
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
print(s[l:r], s[l:r].count("A"), s[l:r].count("B"))
continue
if r + 2 <= len_s:
if s[r:r + 2].count("A") == 1 and \
s[r:r + 2].count("B") == 1:
r += 2
print(s[l:r], s[l:r].count("A"), s[l:r].count("B"))
continue
l += 1
r += 1
print(r - l)
yn