結果

問題 No.927 Second Permutation
ユーザー tamatotamato
提出日時 2019-11-22 21:28:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 334 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 75,520 KB
最終ジャッジ日時 2024-04-19 10:31:35
合計ジャッジ時間 3,238 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,760 KB
testcase_01 AC 45 ms
53,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 46 ms
53,248 KB
testcase_06 AC 45 ms
53,632 KB
testcase_07 AC 46 ms
53,632 KB
testcase_08 AC 65 ms
65,664 KB
testcase_09 AC 50 ms
60,288 KB
testcase_10 AC 74 ms
68,864 KB
testcase_11 AC 92 ms
74,112 KB
testcase_12 AC 72 ms
67,584 KB
testcase_13 AC 56 ms
61,056 KB
testcase_14 AC 83 ms
69,248 KB
testcase_15 AC 71 ms
66,816 KB
testcase_16 AC 98 ms
75,520 KB
testcase_17 AC 96 ms
75,008 KB
testcase_18 AC 96 ms
74,880 KB
testcase_19 AC 96 ms
75,008 KB
testcase_20 AC 97 ms
75,392 KB
testcase_21 AC 96 ms
75,008 KB
testcase_22 AC 94 ms
75,136 KB
testcase_23 AC 93 ms
75,008 KB
testcase_24 AC 60 ms
67,072 KB
testcase_25 AC 60 ms
64,896 KB
testcase_26 AC 58 ms
63,232 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

x = input()
c = Counter(x)

if len(c.keys()) == 1:
    print(-1)
    exit()

ans = sorted(x, reverse=True)
for i in range(len(ans)-1, -1, -1):
    if ans[i] != ans[i-1]:
        ans[i], ans[i-1] = ans[i-1], ans[i]
        break

if ans[0] == 0:
    print(-1)
    exit()

print(''.join(map(str, ans)))
0