結果

問題 No.927 Second Permutation
ユーザー mkawa2mkawa2
提出日時 2022-04-29 17:13:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,036 KB
実行使用メモリ 11,860 KB
最終ジャッジ日時 2023-09-11 08:24:51
合計ジャッジ時間 4,560 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,316 KB
testcase_01 AC 16 ms
8,316 KB
testcase_02 AC 16 ms
8,328 KB
testcase_03 AC 17 ms
8,176 KB
testcase_04 AC 16 ms
8,188 KB
testcase_05 AC 16 ms
8,324 KB
testcase_06 AC 16 ms
8,348 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 50 ms
9,216 KB
testcase_25 AC 39 ms
8,928 KB
testcase_26 AC 33 ms
8,904 KB
testcase_27 AC 30 ms
8,668 KB
testcase_28 AC 49 ms
9,116 KB
testcase_29 AC 42 ms
8,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

aa = list(map(int, SI()))
aa.sort(reverse=True)
i = len(aa)-2
while i >= 0 and aa[i] == aa[-1]:
    i -= 1
if i == -1 or i == 0 and aa[-1] == 0:
    print(-1)
    exit()

aa[i], aa[-1] = aa[-1], aa[i]

print(*aa, sep="")
0