結果

問題 No.1707 Simple Range Reverse Problem
ユーザー 👑 rin204rin204
提出日時 2021-12-13 01:42:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 76,196 KB
最終ジャッジ日時 2023-09-28 20:30:40
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,344 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 79 ms
75,632 KB
testcase_08 WA -
testcase_09 AC 78 ms
75,892 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 78 ms
75,632 KB
testcase_13 AC 78 ms
75,716 KB
testcase_14 AC 78 ms
75,672 KB
testcase_15 AC 78 ms
75,616 KB
testcase_16 AC 79 ms
75,736 KB
testcase_17 AC 79 ms
75,804 KB
testcase_18 AC 79 ms
75,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    A = list(map(int, input().split()))
    B = []
    ok = True
    for i in range(n):
        B.append(i + 1)
        if A[i] != A[i + n]:
            ok = False
    if ok:
        print("Yes")
        return
    l = r = -1
    for i in range(n):
        B.append(i + 1)
        if A[i] == A[i + n]:
            l = i
            r = i + n
    if l == -1:
        print("No")
        return
    A[l:r+1] = A[l:r+1][::-1]
    if A == B:
        print("Yes")
    else:
        print("No")

for _ in range(int(input())):
    solve()
0