結果
問題 | No.927 Second Permutation |
ユーザー |
![]() |
提出日時 | 2020-04-14 10:22:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 447 bytes |
コンパイル時間 | 107 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-10-01 16:51:38 |
合計ジャッジ時間 | 1,934 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 RE * 21 |
ソースコード
x = int(input()) s = list(str(x)) if len(set(s)) == 1: print(-1) exit() s = [int(i) for i in s] #s.sort(reverse=True) d = {} for i in s: if i in d: d[i] += 1 else: d[i] = 1 #print(d) keys = list(d.keys()) keys.sort(reverse=True) ans = [] for k in keys: ans += [k]*d[k] last = d[k] ans[-last-1], ans[-last] = ans[-last], ans[-last-1] if ans[0] == 0: print(-1) else: print(''.join(map(str, ans)))