結果

問題 No.1707 Simple Range Reverse Problem
ユーザー recurakirecuraki
提出日時 2021-10-15 22:35:10
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 80,428 KB
最終ジャッジ日時 2023-10-17 20:33:06
合計ジャッジ時間 2,910 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
74,440 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 92 ms
79,912 KB
testcase_09 AC 93 ms
79,928 KB
testcase_10 AC 92 ms
79,928 KB
testcase_11 AC 93 ms
79,928 KB
testcase_12 AC 92 ms
79,936 KB
testcase_13 AC 93 ms
79,952 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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):
        if l[i+1] == (i+1)%n + 1: continue
        #print("hit", i, l[i])

        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:]
    print("Yes")



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