結果

問題 No.927 Second Permutation
ユーザー titia
提出日時 2019-11-22 21:31:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 262 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-10-11 02:53:31
合計ジャッジ時間 2,364 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

X=sorted(list(input()),reverse=True)
if X[0]==X[-1]:
    print(-1)
elif len(X)==2 and X[-1]=="0":
    print(-1)
else:
    t=-1
    while X[t]==X[-1]:
        t-=1
    X[t],X[t+1]=X[t+1],X[t]
    if X[0]=="0":
        print(-1)
    else:
        print("".join(X))
0