結果

問題 No.1707 Simple Range Reverse Problem
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-10-15 21:59:32
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 59,496 KB
最終ジャッジ日時 2023-10-17 20:17:19
合計ジャッジ時間 1,750 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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