結果

問題 No.927 Second Permutation
ユーザー tamato
提出日時 2019-11-22 21:26:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 361 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 81,988 KB
実行使用メモリ 75,900 KB
最終ジャッジ日時 2024-10-11 02:49:21
合計ジャッジ時間 3,449 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

x = input()
c = Counter(x)

if len(c.keys()) == 1:
    print(-1)
    exit()

if len(c.keys()) == 2 and '0' in c.keys():
    print(-1)
    exit()

ans = sorted(x, reverse=True)
for i in range(len(ans)-1, -1, -1):
    if ans[i] != ans[i-1]:
        ans[i], ans[i-1] = ans[i-1], ans[i]
        break

print(''.join(map(str, ans)))
0