結果

問題 No.2518 Adjacent Larger
ユーザー titia
提出日時 2023-10-27 22:15:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 760 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 14,648 KB
最終ジャッジ日時 2024-09-25 14:18:34
合計ジャッジ時間 3,756 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
"""
from itertools import permutations

AL=list(permutations(range(6)))

for A in AL:
    A=list(A)
    S=[0]*len(A)

    for i in range(len(A)):
        score=0
        for j in [A[i-1],A[(i+1)%len(A)]]:
            if j>A[i]:
                score+=1
        S[i]=score

    print(A[:len(A)],S)
"""
T=int(input())
for tests in range(T):
    N=int(input())
    A=list(map(int,input().split()))

    if A==[1]*N:
        print("No")
        continue

    flag=1

    for i in range(N):
        if A[i]==2 and A[i-1]==2:
            flag=0
        if A[i]==0 and A[i-1]==0:
            flag=0

    if flag==0:
        print("No")
        continue

    if sum(A)==N:
        print("Yes")
    else:
        print("No")

    
0