結果

問題 No.2518 Adjacent Larger
ユーザー lloyzlloyz
提出日時 2023-10-28 21:40:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 81,872 KB
実行使用メモリ 103,008 KB
最終ジャッジ日時 2023-10-28 21:40:59
合計ジャッジ時間 4,543 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,608 KB
testcase_01 AC 227 ms
78,704 KB
testcase_02 AC 233 ms
79,032 KB
testcase_03 AC 223 ms
78,788 KB
testcase_04 AC 242 ms
78,808 KB
testcase_05 AC 223 ms
78,620 KB
testcase_06 AC 109 ms
76,500 KB
testcase_07 AC 127 ms
76,476 KB
testcase_08 AC 124 ms
76,452 KB
testcase_09 AC 111 ms
76,488 KB
testcase_10 AC 112 ms
76,408 KB
testcase_11 AC 73 ms
75,696 KB
testcase_12 AC 74 ms
75,716 KB
testcase_13 AC 80 ms
75,788 KB
testcase_14 AC 65 ms
73,872 KB
testcase_15 AC 65 ms
74,052 KB
testcase_16 AC 97 ms
103,008 KB
testcase_17 AC 75 ms
86,024 KB
testcase_18 AC 73 ms
86,056 KB
testcase_19 AC 72 ms
83,916 KB
testcase_20 AC 82 ms
92,768 KB
testcase_21 AC 88 ms
102,160 KB
testcase_22 AC 85 ms
102,160 KB
testcase_23 AC 91 ms
102,940 KB
testcase_24 AC 84 ms
99,980 KB
testcase_25 AC 84 ms
102,248 KB
testcase_26 AC 86 ms
102,268 KB
testcase_27 AC 81 ms
100,184 KB
testcase_28 AC 84 ms
100,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n = int(input())
    A = list(map(int, input().split()))
    if 2 not in A:
        print("No")
        continue
    idx = A.index(2)
    D = [None for _ in range(n)]
    for i in range(n):
        j = (i + idx) % n
        if A[j] == 2:
            to = '>'
        elif A[j] == 0:
            to = '<'
        else:
            to = D[(j - 1) % n]
        D[j] = to
    flag = True
    for i in range(n):
        if A[i] != (D[(i - 1) % n] == '<') + (D[i] == '>'):
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")
0