結果

問題 No.927 Second Permutation
ユーザー tamato
提出日時 2019-11-22 21:28:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 334 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 82,600 KB
実行使用メモリ 76,448 KB
最終ジャッジ日時 2024-10-11 02:50:58
合計ジャッジ時間 2,918 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 22 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

x = input()
c = Counter(x)

if len(c.keys()) == 1:
    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

if ans[0] == 0:
    print(-1)
    exit()

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