結果

問題 No.1707 Simple Range Reverse Problem
ユーザー gr1msl3ygr1msl3y
提出日時 2021-10-15 21:43:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 59,364 KB
最終ジャッジ日時 2023-10-17 20:10:24
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

def main():
    T = int(input())
    ans = []
    for _ in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        ans.append('Yes' if solve(N, A) else 'No')
    print(*ans, sep='\n')


def solve(N, A):
    w = 0
    for i in range(N):
        if not A[i] == A[i+N] == i+1:
            break
    else:
        return True
    for i in range(N):
        if A[i] != i+1:
            w = i
            break
    else:
        w = N
    for i in range(w, 2*w-1):
        if A[i] != 2*w-i-1:
            return False
    for i in range(2*w-1, w+N):
        if A[i] != N+2*w-i-1:
            return False
    for i in range(w+N, 2*N):
        if A[i] != i-N+1:
            return False
    else:
        return True


main()
0