結果

問題 No.2063 ±2^k operations (easy)
ユーザー 👑 KazunKazun
提出日時 2022-09-02 21:23:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 72,620 KB
最終ジャッジ日時 2024-04-27 20:47:15
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
52,056 KB
testcase_01 AC 31 ms
52,936 KB
testcase_02 AC 30 ms
52,480 KB
testcase_03 WA -
testcase_04 AC 30 ms
52,488 KB
testcase_05 AC 31 ms
52,952 KB
testcase_06 AC 29 ms
52,764 KB
testcase_07 AC 31 ms
52,276 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 31 ms
52,936 KB
testcase_11 AC 29 ms
52,200 KB
testcase_12 AC 30 ms
52,380 KB
testcase_13 AC 30 ms
52,872 KB
testcase_14 AC 32 ms
52,196 KB
testcase_15 WA -
testcase_16 AC 31 ms
52,492 KB
testcase_17 AC 35 ms
60,044 KB
testcase_18 AC 34 ms
60,348 KB
testcase_19 AC 35 ms
60,664 KB
testcase_20 AC 36 ms
60,848 KB
testcase_21 AC 35 ms
59,720 KB
testcase_22 AC 44 ms
71,700 KB
testcase_23 AC 44 ms
72,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Run_Length_Encoding(S):
    """ Run Length 圧縮

    S: 列
    """
    if not S:
        return []

    R=[[S[0],1]]

    for i in range(1,len(S)):
        if R[-1][0]==S[i]:
            R[-1][1]+=1
        else:
            R.append([S[i],1])

    return R
#==================================================
def solve():
    N=input()
    R=Run_Length_Encoding(N)

    if R==[["1",1],["0",len(N)-1]]:
        return False

    cnt=0
    for i,_ in R:
        if i=="1":
            cnt+=1
    return cnt<=2

print("Yes" if solve() else "No")
0