結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-30 00:26:55 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 209 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 12,460 KB |
| 最終ジャッジ日時 | 2024-11-06 22:07:51 |
| 合計ジャッジ時間 | 2,814 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
x = list(input())
x.sort(reverse=True)
y = sorted(x, reverse=True)
z_flag = False
las_ind = -1
if "0" in x:
while not z_flag:
if x[las_ind] == "0":
las_ind -= 1
else:
z_flag = True
x[las_ind], x[las_ind+1] = x[las_ind+1], x[las_ind]
if x[0] == "0":print(-1)
else:print("".join(x))
else:
y[-1], y[-2] = y[-2], y[-1]
if y[0] == "0" or x == y:
print(-1)
else:print("".join(y))