結果

問題 No.1707 Simple Range Reverse Problem
ユーザー shotoyooshotoyoo
提出日時 2021-10-15 23:41:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 906 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 81,876 KB
実行使用メモリ 68,456 KB
最終ジャッジ日時 2023-10-17 21:31:28
合計ジャッジ時間 2,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,280 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 59 ms
68,264 KB
testcase_05 AC 58 ms
68,124 KB
testcase_06 AC 60 ms
68,268 KB
testcase_07 AC 59 ms
68,128 KB
testcase_08 AC 58 ms
68,176 KB
testcase_09 AC 58 ms
68,200 KB
testcase_10 AC 58 ms
68,200 KB
testcase_11 AC 57 ms
68,192 KB
testcase_12 AC 58 ms
68,204 KB
testcase_13 AC 58 ms
68,204 KB
testcase_14 AC 58 ms
68,204 KB
testcase_15 AC 58 ms
68,200 KB
testcase_16 AC 59 ms
68,200 KB
testcase_17 AC 57 ms
68,192 KB
testcase_18 AC 60 ms
68,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))
# sys.setrecursionlimit(3*10**5+10)
def sub(a):
    t = [[] for _ in range(n+1)]
    for i in range(2*n):
        v = a[i]
        l = []
        if i>0:
            l.append(a[i-1])
        if i+1<2*n:
            l.append(a[i+1])
        t[v].extend(l)
    for i in range(n+1):
        t[i] = tuple(sorted(t[i]))
    return [set(item) for item in t]
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    if set(a)!=set(list(range(1,n+1))*2):
        print("No")
        continue
    s1 = sub(a)
    s2 = sub(list(range(1,n+1)) + list(range(1,n+1)))
#     print(s1,s2)
    if all((s1[i]==s2[i] for i in range(n+1))):
        print("Yes")
    else:
        print("No")
0