結果

問題 No.1707 Simple Range Reverse Problem
ユーザー ygd.ygd.
提出日時 2021-10-19 23:20:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 81,360 KB
実行使用メモリ 74,756 KB
最終ジャッジ日時 2023-10-20 10:53:45
合計ジャッジ時間 2,715 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,280 KB
testcase_01 AC 43 ms
59,256 KB
testcase_02 AC 40 ms
59,256 KB
testcase_03 AC 41 ms
59,256 KB
testcase_04 AC 41 ms
61,304 KB
testcase_05 AC 41 ms
61,304 KB
testcase_06 AC 42 ms
59,256 KB
testcase_07 AC 42 ms
59,256 KB
testcase_08 AC 43 ms
59,256 KB
testcase_09 AC 53 ms
74,640 KB
testcase_10 AC 52 ms
74,656 KB
testcase_11 AC 41 ms
61,304 KB
testcase_12 AC 55 ms
74,668 KB
testcase_13 AC 57 ms
74,684 KB
testcase_14 AC 57 ms
74,644 KB
testcase_15 AC 62 ms
74,728 KB
testcase_16 AC 57 ms
74,668 KB
testcase_17 AC 54 ms
74,660 KB
testcase_18 AC 57 ms
74,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline

def main():
    T = int(input())
    for _ in range(T):
        N = int(input())
        A = list(map(int,input().split()))
        X = [i+1 for i in range(N)]
        X = X + X
        if X == A:
            print('Yes')
            continue
        for i in range(N):
            mid = X[i:i+N+1]
            mid.reverse()
            NX = X[:i] + mid + X[i+N+1:]
            #print(NX)
            if NX == A:
                print('Yes')
                break
        else:
            print('No')

if __name__ == '__main__':
    main()
0