結果

問題 No.2518 Adjacent Larger
ユーザー ntudantuda
提出日時 2023-12-21 23:33:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 100,432 KB
最終ジャッジ日時 2023-12-21 23:33:52
合計ジャッジ時間 4,228 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 161 ms
76,876 KB
testcase_02 AC 205 ms
77,644 KB
testcase_03 AC 168 ms
76,876 KB
testcase_04 AC 163 ms
76,880 KB
testcase_05 AC 167 ms
76,876 KB
testcase_06 AC 104 ms
76,636 KB
testcase_07 AC 111 ms
76,276 KB
testcase_08 AC 104 ms
76,632 KB
testcase_09 AC 104 ms
76,636 KB
testcase_10 AC 111 ms
76,508 KB
testcase_11 AC 61 ms
72,416 KB
testcase_12 AC 59 ms
72,376 KB
testcase_13 AC 65 ms
73,208 KB
testcase_14 AC 58 ms
72,388 KB
testcase_15 AC 71 ms
75,388 KB
testcase_16 AC 82 ms
100,392 KB
testcase_17 AC 65 ms
82,808 KB
testcase_18 AC 95 ms
82,828 KB
testcase_19 AC 64 ms
80,868 KB
testcase_20 AC 71 ms
89,336 KB
testcase_21 AC 72 ms
95,856 KB
testcase_22 AC 70 ms
95,856 KB
testcase_23 AC 81 ms
100,432 KB
testcase_24 AC 74 ms
98,108 KB
testcase_25 AC 75 ms
98,224 KB
testcase_26 AC 76 ms
98,352 KB
testcase_27 AC 74 ms
98,224 KB
testcase_28 AC 77 ms
98,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    N = int(input())
    A = list(map(int, input().split()))
    if sum(A) != N:
        print("No")
        continue
    if 0 not in A:
        print("No")
        continue
    j = A.index(0)
    f = 0
    ans = True
    for i in range(1, N + 1):
        if f == 0:
            if A[(i + j) % N] == 0:
                ans = False
                break
            if A[(i + j) % N] == 2:
                f = 2
        elif f == 2:
            if A[(i + j) % N] == 2:
                ans = False
                break
            if A[(i + j) % N] == 0:
                f = 0
    if ans:
        print("Yes")
    else:
        print("No")
0