結果

問題 No.2518 Adjacent Larger
ユーザー atcoder8
提出日時 2023-10-27 23:21:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 97,280 KB
最終ジャッジ日時 2024-09-25 15:19:13
合計ジャッジ時間 4,117 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    aa = list(map(int, input().split()))

    zero = aa.count(0)
    if zero == 0 or zero > n // 2:
        return False

    one = aa.count(0)
    if one == 0 or one > n // 2:
        return False

    if zero != one:
        return False

    for i in range(n):
        if aa[i] == aa[(i + 1) % n] and aa[i] in (0, 2):
            return False

    return True

t = int(input())
for _ in range(t):
    print("Yes" if solve() else "No")
0