結果

問題 No.39 桁の数字を入れ替え
ユーザー Konton7Konton7
提出日時 2019-04-28 10:59:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 448 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 8,488 KB
最終ジャッジ日時 2023-08-21 17:05:10
合計ジャッジ時間 2,316 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,240 KB
testcase_01 AC 18 ms
8,244 KB
testcase_02 AC 18 ms
8,272 KB
testcase_03 AC 18 ms
8,372 KB
testcase_04 AC 18 ms
8,488 KB
testcase_05 AC 19 ms
8,304 KB
testcase_06 AC 19 ms
8,440 KB
testcase_07 AC 18 ms
8,432 KB
testcase_08 AC 19 ms
8,312 KB
testcase_09 AC 18 ms
8,384 KB
testcase_10 AC 18 ms
8,240 KB
testcase_11 AC 19 ms
8,440 KB
testcase_12 AC 19 ms
8,296 KB
testcase_13 AC 19 ms
8,436 KB
testcase_14 AC 18 ms
8,440 KB
testcase_15 AC 19 ms
8,304 KB
testcase_16 AC 18 ms
8,300 KB
testcase_17 AC 18 ms
8,460 KB
testcase_18 AC 18 ms
8,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import copy

s = list(input())
ls = len(s)

def swap(a,b,c):
    x = copy.deepcopy(c)
    x[a], x[b] = x[b], x[a]
    return x 

swplist = [ [ (i,j) for j in range(i+1,ls) ]  for i in range(ls)]

stringlist = ["".join(s)]

for i in range(len(swplist)):
    for j in range(len(swplist[i])):
        b, e = swplist[i][j][0], swplist[i][j][1]
        stringlist.append("".join(swap(b,e,s)))

anslist = sorted(stringlist)
print(anslist[-1])
0