結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2020-04-10 14:53:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 529 bytes |
コンパイル時間 | 483 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-09-15 02:10:44 |
合計ジャッジ時間 | 2,732 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 27 |
ソースコード
from collections import Counter x = list(input()) ctr = Counter(x) t = 0 if ctr['0']==0: if len(ctr.keys())==1: print(-1) exit() else: t = 0 for i in range(1, 10): t += ctr[str(i)] if t==1: print(-1) exit() d = dict(sorted(ctr.items(), reverse=True)) ret = '' for k,v in d.items(): ret += k*v for i in range(len(ret))[::-1]: if ret[i]!=ret[i-1]: ans = ret[:i-1]+ret[i]+ret[i-1]+ret[i+1:] break print(ans)