結果
| 問題 |
No.1707 Simple Range Reverse Problem
|
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2023-09-24 11:54:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 848 bytes |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 82,516 KB |
| 実行使用メモリ | 136,484 KB |
| 最終ジャッジ日時 | 2024-07-17 12:49:41 |
| 合計ジャッジ時間 | 5,124 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 TLE * 1 -- * 9 |
ソースコード
# 作れる全パターンを作ってみるか
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')
FromBooska