結果

問題 No.1707 Simple Range Reverse Problem
ユーザー FromBooskaFromBooska
提出日時 2023-09-24 11:54:45
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 848 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 135,424 KB
最終ジャッジ日時 2023-09-24 11:54:54
合計ジャッジ時間 5,575 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
76,188 KB
testcase_01 AC 125 ms
78,024 KB
testcase_02 AC 145 ms
79,448 KB
testcase_03 AC 147 ms
79,812 KB
testcase_04 AC 253 ms
79,812 KB
testcase_05 AC 242 ms
79,652 KB
testcase_06 AC 183 ms
78,480 KB
testcase_07 AC 186 ms
78,292 KB
testcase_08 AC 194 ms
78,960 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 作れる全パターンを作ってみるか

from collections import deque

T = int(input())
for t in range(T):
    N = int(input())
    A = tuple(list(map(int, input().split())))
    B = [a for a in range(1, N+1)]+[a for a in range(1, N+1)]
    que = deque()
    que.append(B)
    visited = set()
    visited.add(tuple(B))
    while que:
        current = que.popleft()
        test = False
        for i in range(N*2):
            for j in range(i+1, N*2):
                if current[i]==current[j] and j-i>1:
                    temp = current[:i]+current[i:j+1][::-1]+current[j+1:]
                    if tuple(temp) not in visited:
                        visited.add(tuple(temp))
                        que.append(temp)

    #print(len(visited))
    #print(visited)
    if A in visited:
        print('Yes')
    else:
        print('No')
0