結果

問題 No.397 NO MORE KADOMATSU
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-07-16 09:54:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 24,324 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:20:39
合計ジャッジ時間 2,590 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
24,168 KB
testcase_01 AC 38 ms
23,940 KB
testcase_02 AC 38 ms
23,592 KB
testcase_03 AC 40 ms
23,352 KB
testcase_04 AC 38 ms
23,704 KB
testcase_05 AC 42 ms
24,000 KB
testcase_06 AC 39 ms
23,772 KB
testcase_07 AC 40 ms
23,472 KB
testcase_08 AC 39 ms
23,940 KB
testcase_09 AC 39 ms
23,492 KB
testcase_10 AC 41 ms
24,264 KB
testcase_11 AC 38 ms
24,168 KB
testcase_12 AC 40 ms
24,048 KB
testcase_13 AC 42 ms
24,324 KB
testcase_14 AC 41 ms
23,940 KB
testcase_15 AC 42 ms
23,516 KB
testcase_16 AC 40 ms
24,024 KB
testcase_17 AC 38 ms
23,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3
nya = lambda msg: print(msg, flush=True)

n = int(input())
a = list(map(int, input().split()))
b = sorted(a)

arr = []
for i in range(n):
    if a[i] == b[i]:
        continue
    for j in range(i+1, n):
        if a[j] == b[i]:
            arr.append((i, j))
            a[i], a[j] = a[j], a[i]
            break

m = len(arr)
nya(m)
for x, y in arr:
    nya('{} {}'.format(x, y))
0