結果

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

ソースコード

diff #

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

    zero_num = aa.count(0)
    two_num = aa.count(2)

    if (
        zero_num == 0
        or zero_num > n // 2
        or two_num == 0
        or two_num > n // 2
        or zero_num != two_num
    ):
        return False

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

    return True


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


main()
0