結果

問題 No.2518 Adjacent Larger
ユーザー ああいいああいい
提出日時 2023-11-11 22:26:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 1,070 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 103,696 KB
最終ジャッジ日時 2023-11-11 22:26:52
合計ジャッジ時間 5,245 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 383 ms
81,740 KB
testcase_02 AC 248 ms
78,536 KB
testcase_03 AC 291 ms
79,256 KB
testcase_04 AC 261 ms
78,820 KB
testcase_05 AC 253 ms
78,624 KB
testcase_06 AC 125 ms
76,632 KB
testcase_07 AC 119 ms
76,492 KB
testcase_08 AC 126 ms
76,348 KB
testcase_09 AC 126 ms
76,352 KB
testcase_10 AC 120 ms
76,496 KB
testcase_11 AC 60 ms
72,512 KB
testcase_12 AC 61 ms
72,900 KB
testcase_13 AC 64 ms
73,180 KB
testcase_14 AC 61 ms
72,500 KB
testcase_15 AC 59 ms
72,496 KB
testcase_16 AC 87 ms
101,508 KB
testcase_17 AC 68 ms
85,584 KB
testcase_18 AC 70 ms
85,668 KB
testcase_19 AC 66 ms
81,084 KB
testcase_20 AC 80 ms
90,704 KB
testcase_21 AC 82 ms
102,828 KB
testcase_22 AC 83 ms
102,828 KB
testcase_23 AC 88 ms
103,696 KB
testcase_24 AC 82 ms
101,312 KB
testcase_25 AC 83 ms
102,316 KB
testcase_26 AC 85 ms
102,444 KB
testcase_27 AC 86 ms
103,084 KB
testcase_28 AC 86 ms
101,548 KB
権限があれば一括ダウンロードができます

ソースコード

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

    if N == 2:
        if dp[0] == 1 and dp[1] == 0 and dp[-1] == 1:
            print('Yes')
        else:
            print('No')
        continue
    
    flag = True
    for i in range(3):
        if i == 1:continue
        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