結果

問題 No.927 Second Permutation
ユーザー もりをもりを
提出日時 2019-11-22 21:27:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 65,920 KB
最終ジャッジ日時 2024-04-19 10:30:27
合計ジャッジ時間 2,328 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
51,712 KB
testcase_01 AC 32 ms
51,712 KB
testcase_02 AC 31 ms
51,712 KB
testcase_03 AC 32 ms
52,224 KB
testcase_04 AC 34 ms
51,712 KB
testcase_05 AC 33 ms
51,968 KB
testcase_06 AC 32 ms
51,968 KB
testcase_07 AC 32 ms
51,584 KB
testcase_08 AC 42 ms
60,672 KB
testcase_09 AC 31 ms
52,096 KB
testcase_10 AC 49 ms
62,080 KB
testcase_11 AC 58 ms
65,536 KB
testcase_12 AC 48 ms
60,800 KB
testcase_13 AC 33 ms
52,608 KB
testcase_14 AC 48 ms
62,976 KB
testcase_15 AC 45 ms
60,928 KB
testcase_16 AC 59 ms
65,408 KB
testcase_17 AC 61 ms
65,664 KB
testcase_18 AC 61 ms
65,536 KB
testcase_19 AC 63 ms
65,792 KB
testcase_20 AC 62 ms
65,792 KB
testcase_21 AC 61 ms
65,280 KB
testcase_22 AC 60 ms
65,536 KB
testcase_23 AC 60 ms
65,920 KB
testcase_24 AC 41 ms
63,872 KB
testcase_25 AC 39 ms
61,952 KB
testcase_26 AC 38 ms
60,672 KB
testcase_27 AC 39 ms
60,288 KB
testcase_28 AC 40 ms
63,872 KB
testcase_29 AC 39 ms
63,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = list(input())
n = len(s)
s = sorted(s)[::-1]

for i in range(n - 1):
    # s[-1-i]とs[-2-i]
    if s[-1-i] == s[-2-i]:
        continue
    s[-1-i], s[-2-i] = s[-2-i], s[-1-i]
    if s[0] == '0':
        s[-1-i], s[-2-i] = s[-2-i], s[-1-i]
        continue
    print(''.join(s))
    exit()
print(-1)
0