結果

問題 No.1707 Simple Range Reverse Problem
ユーザー FromBooskaFromBooska
提出日時 2023-09-24 18:59:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 77,616 KB
最終ジャッジ日時 2023-09-24 18:59:39
合計ジャッジ時間 3,354 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,604 KB
testcase_01 AC 87 ms
76,628 KB
testcase_02 AC 89 ms
76,928 KB
testcase_03 AC 86 ms
76,668 KB
testcase_04 AC 87 ms
76,816 KB
testcase_05 AC 85 ms
76,640 KB
testcase_06 AC 88 ms
76,656 KB
testcase_07 AC 85 ms
76,816 KB
testcase_08 AC 87 ms
76,808 KB
testcase_09 AC 110 ms
77,572 KB
testcase_10 AC 110 ms
77,444 KB
testcase_11 AC 101 ms
77,616 KB
testcase_12 AC 120 ms
77,420 KB
testcase_13 AC 125 ms
77,228 KB
testcase_14 AC 103 ms
77,320 KB
testcase_15 AC 114 ms
77,388 KB
testcase_16 AC 103 ms
77,308 KB
testcase_17 AC 99 ms
77,108 KB
testcase_18 AC 103 ms
77,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 作れるパターンをリストアウトしてわかったのだが操作は0回か1回しかない
# ということは最初からAになっているか、操作1回するかでAになるかだけ調べればいいか

T = int(input())
for t in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    B = [a for a in range(1, N+1)]+[a for a in range(1, N+1)]
    ans = 'No'
    if A == B:
        ans = 'Yes'
    for i in range(N*2):
        for j in range(i+1, N*2):
            if A[i]==A[j] and j-i>1:
                temp = A[:i]+A[i:j+1][::-1]+A[j+1:]
                if temp == B:
                    ans = 'Yes'
    print(ans)
0