結果

問題 No.1707 Simple Range Reverse Problem
ユーザー 👑 H20H20
提出日時 2021-10-15 21:56:57
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 699 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 75,576 KB
最終ジャッジ日時 2023-10-17 20:16:36
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,556 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 51 ms
61,920 KB
testcase_08 AC 50 ms
61,924 KB
testcase_09 AC 48 ms
61,920 KB
testcase_10 AC 48 ms
61,920 KB
testcase_11 AC 47 ms
61,916 KB
testcase_12 AC 48 ms
61,920 KB
testcase_13 AC 48 ms
61,920 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 58 ms
75,576 KB
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

def func():
    N = int(input())
    A = list(map(int, input().split()))
    CA = collections.Counter(A)
    for v in CA.values():
        if v!=2:
            print('No')
            return
    if A[0]!=1 or A[-1]!=N: 
        print('No')
        return

    for i in range(N):
        if A[i]!=i+1:
            j = i+A[i:].index(A[i-1])
            A = A[:i]+A[i:j][::-1]+A[j:]
        if A[2*N-i-1]!=N-i:
            j = 2*N-i
            i = A.index(A[2*N-i])+1
            A = A[:i]+A[i:j][::-1]+A[j:]
    for i in range(N):
        if A[i]!=i+1 or A[i+N]!=i+1:
            print('No')
            return
    print('Yes')



T = int(input())
for _ in range(T):
    func()


0