結果

問題 No.1707 Simple Range Reverse Problem
ユーザー titia
提出日時 2021-10-15 21:55:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,136 KB
実行使用メモリ 75,248 KB
最終ジャッジ日時 2024-09-17 17:27:54
合計ジャッジ時間 1,869 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
for tests in range(T):
    N=int(input())
    A=list(map(int,input().split()))

    X=list(range(1,N+1))*2

    if X==A:
        print("Yes")
        continue

    for i in range(N):
        Y=X[:i]+X[i:i+N+1][::-1]+X[i+N+1:]
        #print(Y)
        if Y==A:
            print("Yes")
            break
    else:
        print("No")
0