結果

問題 No.927 Second Permutation
ユーザー OhnumaOhnuma
提出日時 2020-04-10 14:47:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,632 KB
実行使用メモリ 9,324 KB
最終ジャッジ日時 2023-10-13 04:30:53
合計ジャッジ時間 2,234 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,436 KB
testcase_01 AC 19 ms
8,300 KB
testcase_02 AC 18 ms
8,484 KB
testcase_03 AC 19 ms
8,272 KB
testcase_04 AC 18 ms
8,288 KB
testcase_05 AC 18 ms
8,332 KB
testcase_06 AC 18 ms
8,408 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 27 ms
9,172 KB
testcase_25 AC 24 ms
8,932 KB
testcase_26 AC 22 ms
8,936 KB
testcase_27 AC 21 ms
8,608 KB
testcase_28 AC 26 ms
9,256 KB
testcase_29 AC 24 ms
9,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
x = list(input())
ctr = Counter(x)
if len(ctr.keys()) - ctr['0'] <= 1:
    print(-1)
else:
    d = dict(sorted(ctr.items(), reverse=True))
    ret = ''    
    for k,v in d.items():
        ret += k*v
    for i in range(len(ret))[::-1]:
        if ret[i]!=ret[i-1]:
            ans = ret[:i-1]+ret[i]+ret[i-1]+ret[i+1:]
            break
    print(ans)
0