結果

問題 No.1707 Simple Range Reverse Problem
ユーザー H3PO4H3PO4
提出日時 2021-10-15 21:45:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 596 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 59,500 KB
最終ジャッジ日時 2023-10-17 20:11:19
合計ジャッジ時間 1,950 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,464 KB
testcase_01 AC 41 ms
59,480 KB
testcase_02 AC 42 ms
59,500 KB
testcase_03 AC 42 ms
59,500 KB
testcase_04 AC 41 ms
59,500 KB
testcase_05 AC 41 ms
59,500 KB
testcase_06 AC 42 ms
59,500 KB
testcase_07 AC 42 ms
59,500 KB
testcase_08 AC 41 ms
59,500 KB
testcase_09 AC 42 ms
59,500 KB
testcase_10 AC 41 ms
59,500 KB
testcase_11 AC 42 ms
59,500 KB
testcase_12 AC 42 ms
59,500 KB
testcase_13 AC 40 ms
59,500 KB
testcase_14 AC 41 ms
59,500 KB
testcase_15 AC 41 ms
59,500 KB
testcase_16 AC 40 ms
59,500 KB
testcase_17 AC 39 ms
59,500 KB
testcase_18 AC 40 ms
59,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline


def solve(N, A):
    B = list(range(1, N + 1)) * 2
    if A == B:
        return True
    i0 = 0
    for i, a in enumerate(A):
        if a != i + 1:
            i0 = i
            break
    if i0 == 0:
        return False

    for j in range((N - 1) // 2):
        B[i0 + j], B[i0 + N - 2 - j] = B[i0 + N - 2 - j], B[i0 + j]
    return A == B


T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    print('Yes' if solve(N, A) else 'No')
0