結果

問題 No.927 Second Permutation
ユーザー pof
提出日時 2019-12-28 23:21:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 13,104 KB
最終ジャッジ日時 2024-10-12 18:47:46
合計ジャッジ時間 2,346 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

x = list(input())
if len(set(x)) == 1:
    print(-1)
else:
    l = sorted(x)
    for i in range(1,len(l)):
        if l[0] != l[i]:
            l[i-1],l[i]=l[i],l[i-1]
            r=''.join(list(reversed(l)))
            if r[0] == '0':
                print(-1)
            else:
                print(r)
            break
    else:
        print(-1)
0