結果

問題 No.927 Second Permutation
ユーザー _matumo__matumo_
提出日時 2019-12-19 08:56:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 10,500 KB
実行使用メモリ 9,584 KB
最終ジャッジ日時 2023-09-21 06:27:45
合計ジャッジ時間 3,683 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,972 KB
testcase_01 AC 16 ms
8,100 KB
testcase_02 AC 17 ms
7,940 KB
testcase_03 AC 17 ms
7,976 KB
testcase_04 AC 16 ms
7,940 KB
testcase_05 AC 16 ms
7,936 KB
testcase_06 AC 16 ms
7,996 KB
testcase_07 AC 16 ms
8,016 KB
testcase_08 AC 22 ms
8,580 KB
testcase_09 AC 17 ms
7,932 KB
testcase_10 AC 26 ms
8,888 KB
testcase_11 AC 31 ms
9,428 KB
testcase_12 AC 23 ms
8,648 KB
testcase_13 AC 17 ms
8,036 KB
testcase_14 AC 26 ms
8,816 KB
testcase_15 AC 23 ms
8,604 KB
testcase_16 AC 33 ms
9,504 KB
testcase_17 AC 33 ms
9,580 KB
testcase_18 AC 33 ms
9,432 KB
testcase_19 AC 32 ms
9,444 KB
testcase_20 AC 33 ms
9,348 KB
testcase_21 AC 32 ms
9,584 KB
testcase_22 AC 33 ms
9,472 KB
testcase_23 AC 32 ms
9,428 KB
testcase_24 AC 25 ms
8,792 KB
testcase_25 AC 22 ms
8,528 KB
testcase_26 AC 20 ms
8,440 KB
testcase_27 AC 19 ms
8,424 KB
testcase_28 AC 24 ms
8,832 KB
testcase_29 AC 23 ms
8,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
def abc(S):
    s=sorted(S)
    for i in range(len(s)-1):
        if s[i]!=s[i+1]:
            s[i],s[i+1]=s[i+1],s[i]
            if s[-1]=='0':    return -1
            return "".join(s[::-1])
    return -1

def main():
    S=input()
    print(abc(S))

main()
0