結果

問題 No.1707 Simple Range Reverse Problem
ユーザー recurakirecuraki
提出日時 2021-10-15 22:37:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 80,256 KB
最終ジャッジ日時 2023-10-17 20:34:06
合計ジャッジ時間 2,747 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
74,364 KB
testcase_01 AC 92 ms
79,748 KB
testcase_02 AC 94 ms
79,648 KB
testcase_03 AC 94 ms
79,676 KB
testcase_04 AC 94 ms
79,876 KB
testcase_05 AC 92 ms
80,080 KB
testcase_06 AC 94 ms
79,864 KB
testcase_07 AC 91 ms
79,796 KB
testcase_08 AC 91 ms
79,800 KB
testcase_09 AC 91 ms
79,804 KB
testcase_10 AC 91 ms
79,828 KB
testcase_11 AC 93 ms
79,812 KB
testcase_12 AC 93 ms
79,828 KB
testcase_13 AC 91 ms
79,812 KB
testcase_14 AC 93 ms
79,856 KB
testcase_15 AC 104 ms
80,232 KB
testcase_16 AC 92 ms
79,824 KB
testcase_17 AC 103 ms
80,240 KB
testcase_18 AC 102 ms
80,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from pprint import pprint

import math
INF = 1 << 63
def do():
    n = int(input())
    l = list(map(int, input().split()))
    if l[0] != 1:
        print("No")
        return
    if l[-1] != n:
        print("No")
        return
    for i in range(n):
        #print("seek", i, (i+1)%n + 1)
        if l[i+1] == ((i+1)%n + 1): continue

        ll, rr = i, -1
        t = l[i]
        for i in range(ll+1, 2*n):
            if l[i] == t:
                rr = i
                break
        l = l[:ll] + list(reversed(l[ll:rr + 1])) + l[rr+1:]
    for i in range(n):
        if l[0+i] == l[n+i] == (i+1):
            continue
        print("No")
        return
    print("Yes")



# n questions
q = int(input())
for _ in range(q):
    do()
0