結果

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

ソースコード

diff #

T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int,input().split()))
    
    f = True
    f &= sum(A) == N

    for i in range(N):
        if A[i] == 0 and A[(i + 1) % N] == 0:
            f = False
        if A[i] == 2 and A[(i + 1) % N] == 2:
            f = False
    
    f0 = False
    f2 = False
    for i in range(N):
        if A[i] == 0: 
            f0 = True
        if A[i] == 2: 
            f2 = True
    
    if f & f0 & f2 :
        print("Yes")
    else:
        print("No")
0