結果
問題 | No.927 Second Permutation |
ユーザー |
![]() |
提出日時 | 2020-03-09 01:08:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 554 bytes |
コンパイル時間 | 320 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-11-07 20:22:32 |
合計ジャッジ時間 | 2,718 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 20 |
ソースコード
import collections x = list(input()) x = [int(_) for _ in x] c = collections.Counter(x).most_common() c.sort(reverse=True) type = len(c) if type < 2: print(-1) exit() if len(x) == 2 and (x[0] == 0 or x[1] == 0): print(-1) exit() ans = "" for i in range(len(c)): if c[i][1] > 0: ac = str(c[i][0]) * c[i][1] ans += ac for i in range(len(ans)): if ans[len(ans)-1] != ans[len(ans)-1-i]: idx = len(ans)-1-i break #print(ans, idx) print(ans[0:idx] + ans[len(ans)-1] + ans[idx+1:len(ans)-1] + ans[idx])