結果

問題 No.1707 Simple Range Reverse Problem
ユーザー FromBooskaFromBooska
提出日時 2023-02-28 19:37:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,656 KB
実行使用メモリ 76,228 KB
最終ジャッジ日時 2023-10-14 02:29:00
合計ジャッジ時間 3,623 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,956 KB
testcase_01 AC 78 ms
75,352 KB
testcase_02 AC 78 ms
75,364 KB
testcase_03 AC 77 ms
75,420 KB
testcase_04 AC 76 ms
75,336 KB
testcase_05 AC 76 ms
75,424 KB
testcase_06 AC 76 ms
75,384 KB
testcase_07 AC 78 ms
75,356 KB
testcase_08 AC 75 ms
75,476 KB
testcase_09 AC 89 ms
75,940 KB
testcase_10 AC 91 ms
76,096 KB
testcase_11 AC 86 ms
75,956 KB
testcase_12 AC 95 ms
76,092 KB
testcase_13 AC 101 ms
76,116 KB
testcase_14 AC 89 ms
75,948 KB
testcase_15 AC 95 ms
76,008 KB
testcase_16 AC 90 ms
76,088 KB
testcase_17 AC 87 ms
75,936 KB
testcase_18 AC 93 ms
76,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 実験するとわかる
# 123123から派生できる形は、1で交換、2で交換、3で交換の3種だけ、それ以上派生不可能
# 12341234でも同じで4種のみ
# しかし全部パターンのリストを作ると間に合わないか

T = int(input())
for t in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    X = [a for a in range(1, N+1)]*2
    ans = 'No'
    if X == A:
        ans = 'Yes'
    else:
        for i in range(0, N):
            temp = X[:i+1] + X[i+1:i+1+N-1][::-1] + X[i+1+N-1:]
            #print(temp, temp==A)
            if temp == A:
                ans = 'Yes'
    print(ans)
0