結果

問題 No.927 Second Permutation
コンテスト
ユーザー tamato
提出日時 2019-11-22 21:26:49
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 361 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 146 ms
コンパイル使用メモリ 85,072 KB
実行使用メモリ 75,412 KB
最終ジャッジ日時 2026-04-27 08:51:43
合計ジャッジ時間 3,257 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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