結果

問題 No.1707 Simple Range Reverse Problem
ユーザー tcltktcltk
提出日時 2021-10-16 18:56:26
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 877 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 86,604 KB
最終ジャッジ日時 2023-10-17 22:16:01
合計ジャッジ時間 3,509 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
86,096 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 130 ms
86,596 KB
testcase_15 AC 130 ms
86,596 KB
testcase_16 AC 132 ms
86,604 KB
testcase_17 AC 129 ms
86,604 KB
testcase_18 AC 129 ms
86,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

YES = 'Yes'
NO = 'No'

def solve(N, A):
    N //= 2
    for i in range(2*N):
        if A[i] != i % N:
            if i == 0:
                return 'No'
            for j in range(i+1, 2*N):
                if A[j] == A[i-1]:
                    if A[j-1] != i % N:
                        return 'No'
                    A = A[:i] + A[j-1:i-1:-1] + A[j:]
            else:
                return 'No'
    return 'Yes'


T0 = int(input())
for _ in range(T0):
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N//2, A))
0