結果

問題 No.2518 Adjacent Larger
ユーザー ntudantuda
提出日時 2023-12-21 23:32:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 100,432 KB
最終ジャッジ日時 2023-12-21 23:32:15
合計ジャッジ時間 3,600 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 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 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 80 ms
100,392 KB
testcase_17 AC 64 ms
82,808 KB
testcase_18 AC 64 ms
82,828 KB
testcase_19 AC 62 ms
80,868 KB
testcase_20 AC 70 ms
89,336 KB
testcase_21 AC 71 ms
95,856 KB
testcase_22 AC 71 ms
95,856 KB
testcase_23 AC 82 ms
100,432 KB
testcase_24 AC 74 ms
98,108 KB
testcase_25 AC 74 ms
98,224 KB
testcase_26 AC 75 ms
98,352 KB
testcase_27 AC 74 ms
98,224 KB
testcase_28 AC 75 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")
        exit()
    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