結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2025-10-02 12:37:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 431 bytes |
コンパイル時間 | 308 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2025-10-02 12:37:52 |
合計ジャッジ時間 | 3,141 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 22 RE * 5 |
ソースコード
x = input() sorted_x = sorted(x, reverse=True) xs = [] for c in sorted_x: if c == '0': continue xs.append(c) ans = '-1' if len(xs) < 2: print(ans) exit() for i in range(len(x)-1, 0, -1): c1 = sorted_x[i] c2 = sorted_x[i-1] if c1 != c2: list = sorted_x[:i-1] list.append(c1) list.append(c2) list += sorted_x[i+1:] break ans = ''.join(list) print(ans)