結果

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

ソースコード

diff #

t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    aa = [i+1 for i in range(n)] + [i+1 for i in range(n)]
    if a == aa:
        print("Yes")
        continue
    for i in range(n):
        if a[i+1] != ((i + 1) % n + 1):
#             print(a[i],i,(i + 1) % n + 1)
            cnt = 0    
            for j in range(i+n-1,i,-1):
                aa[j] = (i + cnt+1) % n + 1
#                 print(i,j,(i + cnt+1) % n + 1 )
                cnt += 1
            break
    if a == aa:
        print("Yes")
    else:
        print("No")
0