結果

問題 No.2063 ±2^k operations (easy)
ユーザー 👑 KazunKazun
提出日時 2022-09-02 21:26:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 78,480 KB
最終ジャッジ日時 2023-08-10 03:17:46
合計ジャッジ時間 3,077 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,480 KB
testcase_01 AC 70 ms
71,304 KB
testcase_02 AC 70 ms
71,468 KB
testcase_03 AC 70 ms
71,372 KB
testcase_04 AC 68 ms
71,428 KB
testcase_05 AC 70 ms
71,300 KB
testcase_06 AC 70 ms
71,544 KB
testcase_07 AC 68 ms
71,268 KB
testcase_08 AC 70 ms
71,200 KB
testcase_09 AC 68 ms
71,216 KB
testcase_10 AC 68 ms
71,380 KB
testcase_11 AC 68 ms
71,432 KB
testcase_12 AC 69 ms
71,064 KB
testcase_13 AC 69 ms
71,464 KB
testcase_14 AC 69 ms
71,056 KB
testcase_15 AC 68 ms
71,324 KB
testcase_16 AC 68 ms
71,360 KB
testcase_17 AC 73 ms
75,464 KB
testcase_18 AC 74 ms
75,512 KB
testcase_19 AC 73 ms
75,356 KB
testcase_20 AC 74 ms
75,356 KB
testcase_21 AC 74 ms
75,488 KB
testcase_22 AC 78 ms
78,480 KB
testcase_23 AC 79 ms
78,332 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]] or R==[["1",1]]:
        return False

    if len(R)<=2 or N.count("1")==2:
        return True
    else:
        return False

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