結果

問題 No.1604 Swap Sort:ONE
ユーザー mkawa2mkawa2
提出日時 2021-07-16 22:12:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 911 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 13,284 KB
最終ジャッジ日時 2023-09-20 14:18:39
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,548 KB
testcase_01 AC 17 ms
8,152 KB
testcase_02 AC 17 ms
8,352 KB
testcase_03 AC 17 ms
8,224 KB
testcase_04 AC 16 ms
8,292 KB
testcase_05 AC 19 ms
8,896 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

n = II()
aa = LI1()
atoi = {a: i for i, a in enumerate(aa)}
cnt = 0

for i in range(n):
    while aa[i] != i:
        a = aa[i]
        a1 = aa[i]-1
        j = atoi[a1]
        aa[i] = a1
        aa[j] = a
        atoi[a1] = i
        atoi[a] = j
        cnt += 1
        # print(aa)

print(cnt)
0