結果

問題 No.2518 Adjacent Larger
ユーザー ああいいああいい
提出日時 2023-11-11 22:21:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 103,704 KB
最終ジャッジ日時 2023-11-11 22:21:36
合計ジャッジ時間 5,521 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 57 ms
72,512 KB
testcase_12 AC 60 ms
72,900 KB
testcase_13 AC 62 ms
73,180 KB
testcase_14 AC 57 ms
72,500 KB
testcase_15 AC 57 ms
72,496 KB
testcase_16 AC 84 ms
101,508 KB
testcase_17 AC 67 ms
85,584 KB
testcase_18 AC 67 ms
85,668 KB
testcase_19 AC 64 ms
81,084 KB
testcase_20 AC 73 ms
90,708 KB
testcase_21 AC 78 ms
102,828 KB
testcase_22 AC 78 ms
102,828 KB
testcase_23 AC 84 ms
103,704 KB
testcase_24 AC 79 ms
101,316 KB
testcase_25 AC 80 ms
102,316 KB
testcase_26 AC 81 ms
102,444 KB
testcase_27 AC 74 ms
98,220 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

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

    dp = [0] * 3
    for a in A:
        dp[a] +=1
    flag = True
    for i in range(3):
        if dp[i] == 0:
            flag = False
    if not flag:
        print('No')
        continue
    n = 0
    for i in range(N):
        if A[i] == 0:
            n = i
            A = A[i:] + A[:i]
            break
    now = 1
    flag = True
    for i in range(1,N):
        if A[i] == 0:
            if now == 1:
                flag = False
                break
            else:
                now = 1
        elif A[i] == 1:
            pass
        else:
            if now == -1:
                flag = False
                break
            else:now = -1
    if now == 1:
        flag = False
    if flag:
        print('Yes')
    else:
        print('No')
        
            
0