結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
_KingdomOfMoray
|
| 提出日時 | 2020-01-04 23:12:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 462 bytes |
| コンパイル時間 | 140 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-11-22 21:45:10 |
| 合計ジャッジ時間 | 2,078 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 RE * 21 |
ソースコード
import collections
x = int(input())
x_list = list(str(x))
sorted_x = sorted(x_list, reverse=True)
clc = collections.Counter(sorted_x)
num_clc = len(clc.keys())
if num_clc == 1:
res = -1
else:
swap_index = sorted_x.index(min(sorted_x))
sorted_x[swap_index], sorted_x[swap_index - 1] = \
sorted_x[swap_index - 1], sorted_x[swap_index]
if sorted_x[0] == '0':
res = -1
else:
res = ''.join(sorted_x)
print(res)
_KingdomOfMoray