結果

問題 No.2343 (l+r)/2
コンテスト
ユーザー detteiuu
提出日時 2026-07-20 20:05:04
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 174 ms / 2,000 ms
+ 175µs
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 234 ms
コンパイル使用メモリ 96,228 KB
実行使用メモリ 99,088 KB
最終ジャッジ日時 2026-07-20 20:05:09
合計ジャッジ時間 3,356 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline

def RLE(A):
    ans = []
    cnt = 0
    for i in range(len(A)):
        cnt += 1
        if i+1 == len(A) or A[i] != A[i+1]:
            ans.append((A[i], cnt))
            cnt = 0
    return ans

def RLER(A):
    ans = []
    for s, c in A:
        ans.append(s*c)
    return "".join(ans)

from random import randrange
# import A_test

for _ in range(int(input())):
    N = int(input())
    A = list(map(int, input().split()))
    # test
    # N = randrange(1, 11)
    # A = [randrange(2) for _ in range(N)]
    # test

    R = RLE(A)

    if len(R)%2 == 0:
        print("Yes")
        continue
    if 9 <= len(R):
        print("Yes")
        continue

    S = R[0][0]^1
    for n, c in R:
        if n == S and 2 <= c:
            print("Yes")
            break
    else:
        print("No")
0