結果

問題 No.927 Second Permutation
ユーザー c-yanc-yan
提出日時 2020-03-22 01:55:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 298 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 9,316 KB
最終ジャッジ日時 2023-08-25 20:15:51
合計ジャッジ時間 2,213 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,852 KB
testcase_01 AC 15 ms
8,116 KB
testcase_02 AC 15 ms
7,888 KB
testcase_03 AC 15 ms
7,952 KB
testcase_04 AC 15 ms
7,808 KB
testcase_05 AC 15 ms
8,060 KB
testcase_06 AC 15 ms
8,168 KB
testcase_07 AC 15 ms
7,772 KB
testcase_08 AC 22 ms
8,304 KB
testcase_09 AC 16 ms
7,824 KB
testcase_10 AC 26 ms
8,644 KB
testcase_11 AC 34 ms
9,172 KB
testcase_12 AC 23 ms
8,472 KB
testcase_13 AC 16 ms
8,164 KB
testcase_14 AC 26 ms
8,676 KB
testcase_15 AC 23 ms
8,536 KB
testcase_16 AC 36 ms
9,252 KB
testcase_17 AC 36 ms
9,316 KB
testcase_18 AC 35 ms
9,216 KB
testcase_19 AC 35 ms
9,216 KB
testcase_20 AC 35 ms
9,260 KB
testcase_21 AC 35 ms
9,212 KB
testcase_22 AC 35 ms
9,168 KB
testcase_23 AC 34 ms
9,248 KB
testcase_24 AC 16 ms
8,156 KB
testcase_25 AC 16 ms
8,164 KB
testcase_26 AC 16 ms
8,172 KB
testcase_27 AC 25 ms
8,344 KB
testcase_28 AC 41 ms
8,940 KB
testcase_29 AC 35 ms
8,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

X = input()

if len(set(X)) == 1:
    print(-1)
    exit()

t = sorted(X, reverse=True)
Y1 = ''.join(t)

for i in range(len(t) - 2, -1, -1):
    if t[i] != t[len(t) - 1]:
        break

a, b = t[i], t[i + 1]
t[i], t[i + 1] = b, a
Y2 = ''.join(t)

if Y2[0] == '0':
    print(-1)
else:
    print(Y2)
0