結果

問題 No.927 Second Permutation
ユーザー deideirodeideiro
提出日時 2019-11-22 22:10:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 262 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,732 KB
最終ジャッジ日時 2024-04-19 11:36:45
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 28 ms
10,880 KB
testcase_07 AC 28 ms
10,880 KB
testcase_08 AC 56 ms
12,160 KB
testcase_09 AC 29 ms
10,880 KB
testcase_10 AC 69 ms
13,080 KB
testcase_11 AC 98 ms
14,444 KB
testcase_12 AC 63 ms
12,364 KB
testcase_13 AC 33 ms
11,136 KB
testcase_14 AC 74 ms
13,132 KB
testcase_15 AC 59 ms
12,608 KB
testcase_16 AC 105 ms
14,652 KB
testcase_17 AC 106 ms
14,732 KB
testcase_18 AC 108 ms
14,596 KB
testcase_19 AC 105 ms
14,596 KB
testcase_20 AC 103 ms
14,604 KB
testcase_21 AC 104 ms
14,600 KB
testcase_22 AC 107 ms
14,728 KB
testcase_23 AC 107 ms
14,724 KB
testcase_24 AC 83 ms
13,056 KB
testcase_25 AC 59 ms
12,288 KB
testcase_26 AC 51 ms
11,776 KB
testcase_27 AC 46 ms
11,648 KB
testcase_28 AC 72 ms
12,800 KB
testcase_29 AC 69 ms
12,416 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