結果

問題 No.2518 Adjacent Larger
ユーザー miya145592miya145592
提出日時 2023-10-27 22:35:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 103,408 KB
最終ジャッジ日時 2023-10-27 22:35:52
合計ジャッジ時間 4,219 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,444 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 91 ms
76,356 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 84 ms
101,880 KB
testcase_17 AC 68 ms
84,888 KB
testcase_18 AC 67 ms
84,912 KB
testcase_19 AC 64 ms
82,980 KB
testcase_20 AC 73 ms
91,292 KB
testcase_21 AC 75 ms
97,372 KB
testcase_22 AC 74 ms
97,372 KB
testcase_23 AC 89 ms
103,408 KB
testcase_24 AC 82 ms
100,720 KB
testcase_25 AC 83 ms
101,304 KB
testcase_26 AC 82 ms
101,300 KB
testcase_27 AC 78 ms
100,092 KB
testcase_28 AC 84 ms
101,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    D = defaultdict(int)
    flag = True
    for i in range(N):
        if A[i]==A[(i+1)%N]==0 or A[i]==A[(i+1)%N]==2:
            flag = False
            break
        D[A[i]] += 1
    if D[0]==0 or D[2]==0:
        flag = False
    if D[1]+D[2]*2!=N:
        flag = False
    if flag:
        print("Yes")
    else:
        print("No")
            
0