結果

問題 No.1604 Swap Sort:ONE
ユーザー mkawa2mkawa2
提出日時 2021-07-16 22:13:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 77,572 KB
最終ジャッジ日時 2023-09-20 14:20:39
合計ジャッジ時間 5,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,316 KB
testcase_01 AC 74 ms
71,312 KB
testcase_02 AC 74 ms
71,448 KB
testcase_03 AC 74 ms
71,132 KB
testcase_04 AC 78 ms
71,568 KB
testcase_05 AC 80 ms
76,772 KB
testcase_06 AC 267 ms
77,516 KB
testcase_07 AC 176 ms
77,340 KB
testcase_08 AC 175 ms
77,364 KB
testcase_09 AC 178 ms
77,252 KB
testcase_10 AC 180 ms
77,284 KB
testcase_11 AC 177 ms
77,340 KB
testcase_12 AC 180 ms
77,488 KB
testcase_13 AC 180 ms
77,412 KB
testcase_14 AC 179 ms
77,344 KB
testcase_15 AC 174 ms
77,220 KB
testcase_16 AC 177 ms
77,416 KB
testcase_17 AC 114 ms
77,196 KB
testcase_18 AC 114 ms
77,168 KB
testcase_19 AC 168 ms
77,264 KB
testcase_20 AC 113 ms
77,188 KB
testcase_21 AC 169 ms
77,336 KB
testcase_22 AC 148 ms
77,572 KB
testcase_23 AC 87 ms
76,552 KB
testcase_24 AC 82 ms
76,308 KB
testcase_25 AC 172 ms
77,360 KB
testcase_26 AC 131 ms
77,352 KB
権限があれば一括ダウンロードができます

ソースコード

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