結果

問題 No.290 1010
ユーザー 学ぶマン
提出日時 2025-04-28 20:46:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 405 ms / 5,000 ms
コード長 533 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 82,672 KB
実行使用メモリ 241,696 KB
最終ジャッジ日時 2025-04-28 20:46:58
合計ジャッジ時間 3,243 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.set_int_max_str_digits(0)

from itertools import groupby
def runLengthEncode(S): # list でも str でも OK
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, int(len(list(v)))))
    return res

N = int(input())
S = input()

if len(runLengthEncode(S)) == N: # 01010 or 101010

    # 4文字以上あったら 0101 or 1010 2文字のペア同士成立する
    if N >= 4:
        print('YES')
    else:
        print('NO')

else:
    # 縮められる時点で YES
    print('YES')
0