結果

問題 No.1707 Simple Range Reverse Problem
ユーザー yudai1102jpyudai1102jp
提出日時 2021-10-15 22:17:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 10,416 KB
最終ジャッジ日時 2023-10-17 20:25:43
合計ジャッジ時間 1,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,120 KB
testcase_01 AC 31 ms
10,128 KB
testcase_02 AC 31 ms
10,128 KB
testcase_03 AC 30 ms
10,128 KB
testcase_04 AC 31 ms
10,132 KB
testcase_05 AC 31 ms
10,128 KB
testcase_06 AC 32 ms
10,128 KB
testcase_07 AC 32 ms
10,128 KB
testcase_08 AC 31 ms
10,128 KB
testcase_09 AC 32 ms
10,352 KB
testcase_10 AC 31 ms
10,356 KB
testcase_11 AC 30 ms
10,368 KB
testcase_12 AC 31 ms
10,388 KB
testcase_13 AC 31 ms
10,416 KB
testcase_14 AC 31 ms
10,356 KB
testcase_15 AC 31 ms
10,396 KB
testcase_16 AC 30 ms
10,376 KB
testcase_17 AC 30 ms
10,352 KB
testcase_18 AC 31 ms
10,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for t in range(T):
    N = int(input())
    A = list(map(int, input().split()))

    if not(A[0] == 1 and A[-1] == N):
        print('No')
        continue

    flag = False
    chs = 0
    che = 0
    count = {i+1: 0 for i in range(N)}
    for i in range(2*N):
        count[A[i]] += 1
        if A[i] != i % N+1 and not flag:

            chs = i-1
            flag = True
            continue
        if flag and A[i] == A[chs]:
            che = i
    for i in range(N):
        if count[i+1] != 2:
            print('No')
            break
    else:
        for i in range(2*N):
            if chs < i < che:
                i_ = che-(i-chs)
            else:
                i_ = i
            if A[i_] != i % N+1:
                print('No')
                break
        else:
            print('Yes')
0