結果
| 問題 | No.927 Second Permutation |
| コンテスト | |
| ユーザー |
_KingdomOfMoray
|
| 提出日時 | 2020-01-04 23:11:23 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 460 bytes |
| 記録 | |
| コンパイル時間 | 317 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-11-22 21:45:04 |
| 合計ジャッジ時間 | 2,392 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 4 WA * 2 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