結果

問題 No.927 Second Permutation
ユーザー deideirodeideiro
提出日時 2019-11-22 22:10:16
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 262 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 10,612 KB
実行使用メモリ 12,072 KB
最終ジャッジ日時 2023-08-01 12:01:04
合計ジャッジ時間 3,145 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,188 KB
testcase_01 AC 18 ms
8,164 KB
testcase_02 AC 18 ms
8,188 KB
testcase_03 AC 18 ms
8,240 KB
testcase_04 AC 18 ms
8,208 KB
testcase_05 AC 18 ms
8,208 KB
testcase_06 AC 19 ms
8,160 KB
testcase_07 AC 18 ms
8,336 KB
testcase_08 AC 45 ms
9,644 KB
testcase_09 AC 20 ms
8,276 KB
testcase_10 AC 61 ms
10,480 KB
testcase_11 AC 89 ms
11,688 KB
testcase_12 AC 51 ms
9,980 KB
testcase_13 AC 24 ms
8,516 KB
testcase_14 AC 63 ms
10,264 KB
testcase_15 AC 51 ms
9,916 KB
testcase_16 AC 96 ms
12,052 KB
testcase_17 AC 96 ms
11,972 KB
testcase_18 AC 96 ms
11,892 KB
testcase_19 AC 96 ms
12,072 KB
testcase_20 AC 96 ms
11,928 KB
testcase_21 AC 95 ms
11,940 KB
testcase_22 AC 97 ms
11,976 KB
testcase_23 AC 95 ms
11,936 KB
testcase_24 AC 68 ms
10,552 KB
testcase_25 AC 52 ms
9,720 KB
testcase_26 AC 43 ms
9,516 KB
testcase_27 AC 39 ms
9,196 KB
testcase_28 AC 67 ms
10,376 KB
testcase_29 AC 58 ms
9,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder
import copy
X = list(input())
X = sorted(X)[::-1]
XX = copy.deepcopy(X)

for i in range(len(X)-1,0,-1):
    if XX[i] != XX[i-1]:
        XX[i],XX[i-1] = XX[i-1],XX[i]
        break
if XX[0] == "0" or X == XX:
    print(-1)
else:
    print(*XX,sep="")
0