結果

問題 No.2518 Adjacent Larger
ユーザー titiatitia
提出日時 2023-10-28 01:50:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 11,844 KB
実行使用メモリ 13,268 KB
最終ジャッジ日時 2023-10-28 01:50:13
合計ジャッジ時間 4,295 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
9,980 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 53 ms
10,032 KB
testcase_07 AC 61 ms
10,036 KB
testcase_08 AC 52 ms
10,040 KB
testcase_09 AC 52 ms
10,036 KB
testcase_10 AC 52 ms
10,036 KB
testcase_11 AC 51 ms
10,120 KB
testcase_12 AC 53 ms
10,120 KB
testcase_13 AC 50 ms
10,124 KB
testcase_14 AC 53 ms
10,128 KB
testcase_15 AC 51 ms
10,120 KB
testcase_16 AC 133 ms
13,268 KB
testcase_17 AC 89 ms
12,072 KB
testcase_18 AC 87 ms
12,080 KB
testcase_19 AC 75 ms
11,436 KB
testcase_20 AC 100 ms
12,464 KB
testcase_21 AC 152 ms
13,244 KB
testcase_22 AC 136 ms
13,244 KB
testcase_23 AC 154 ms
13,244 KB
testcase_24 AC 164 ms
13,208 KB
testcase_25 AC 167 ms
13,244 KB
testcase_26 AC 167 ms
13,244 KB
testcase_27 AC 110 ms
13,244 KB
testcase_28 AC 104 ms
13,244 KB
権限があれば一括ダウンロードができます

ソースコード

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 A[i]==1:
            if A[i-1]==A[(i+1)%N]==2:
                flag=0
            if A[i-1]==A[(i+1)%N]==0:
                flag=0

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

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

    
0