結果

問題 No.927 Second Permutation
ユーザー toyuzukotoyuzuko
提出日時 2020-03-28 20:05:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 9,436 KB
最終ジャッジ日時 2023-08-30 18:09:08
合計ジャッジ時間 3,004 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,900 KB
testcase_01 AC 17 ms
7,924 KB
testcase_02 AC 15 ms
7,900 KB
testcase_03 AC 15 ms
7,752 KB
testcase_04 AC 16 ms
7,820 KB
testcase_05 AC 15 ms
7,752 KB
testcase_06 AC 15 ms
7,812 KB
testcase_07 AC 16 ms
7,752 KB
testcase_08 AC 28 ms
8,652 KB
testcase_09 AC 16 ms
7,740 KB
testcase_10 AC 35 ms
8,696 KB
testcase_11 AC 46 ms
9,068 KB
testcase_12 AC 31 ms
8,596 KB
testcase_13 AC 17 ms
8,196 KB
testcase_14 AC 35 ms
8,792 KB
testcase_15 AC 30 ms
8,660 KB
testcase_16 AC 49 ms
9,436 KB
testcase_17 AC 48 ms
9,268 KB
testcase_18 AC 50 ms
9,132 KB
testcase_19 AC 49 ms
9,224 KB
testcase_20 AC 50 ms
9,180 KB
testcase_21 AC 49 ms
9,388 KB
testcase_22 AC 50 ms
9,304 KB
testcase_23 AC 50 ms
9,236 KB
testcase_24 AC 44 ms
8,228 KB
testcase_25 AC 34 ms
8,264 KB
testcase_26 AC 30 ms
8,284 KB
testcase_27 AC 27 ms
8,220 KB
testcase_28 AC 43 ms
8,256 KB
testcase_29 AC 37 ms
8,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

X = input()
N = [0 for _ in range(10)]

for x in X:
    N[int(x)] += 1

if sum([bool(n) for n in N]) == 1:
    print(-1)
elif sum(N[1:]) == 1:
    print(-1)
else:
    res = []
    for i in range(10)[::-1]:
        res.extend([str(i)] * N[i])
    for i in range(len(res) - 1)[::-1]:
        if res[i] != res[i + 1]:
            res[i], res[i + 1] = res[i + 1], res[i]
            break
    print(''.join(res))
0