結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
Ohnuma
|
| 提出日時 | 2020-04-10 14:47:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 384 bytes |
| コンパイル時間 | 119 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-09-15 02:03:14 |
| 合計ジャッジ時間 | 2,159 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 17 |
ソースコード
from collections import Counter
x = list(input())
ctr = Counter(x)
if len(ctr.keys()) - ctr['0'] <= 1:
print(-1)
else:
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)
Ohnuma