結果

問題 No.927 Second Permutation
ユーザー na-shna-sh
提出日時 2020-01-06 15:36:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 968 ms / 2,000 ms
コード長 301 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 10,600 KB
実行使用メモリ 16,952 KB
最終ジャッジ日時 2023-08-14 22:42:08
合計ジャッジ時間 7,463 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,812 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 15 ms
7,900 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 AC 15 ms
7,776 KB
testcase_05 AC 15 ms
7,776 KB
testcase_06 AC 15 ms
7,892 KB
testcase_07 AC 15 ms
8,004 KB
testcase_08 AC 54 ms
11,172 KB
testcase_09 AC 17 ms
8,248 KB
testcase_10 AC 99 ms
13,240 KB
testcase_11 AC 216 ms
16,392 KB
testcase_12 AC 66 ms
11,820 KB
testcase_13 AC 19 ms
8,784 KB
testcase_14 AC 99 ms
13,424 KB
testcase_15 AC 65 ms
11,824 KB
testcase_16 AC 261 ms
16,600 KB
testcase_17 AC 243 ms
16,952 KB
testcase_18 AC 255 ms
16,908 KB
testcase_19 AC 248 ms
16,904 KB
testcase_20 AC 248 ms
16,816 KB
testcase_21 AC 257 ms
16,852 KB
testcase_22 AC 257 ms
16,848 KB
testcase_23 AC 250 ms
16,900 KB
testcase_24 AC 968 ms
9,624 KB
testcase_25 AC 455 ms
8,944 KB
testcase_26 AC 268 ms
8,900 KB
testcase_27 AC 186 ms
8,776 KB
testcase_28 AC 865 ms
9,216 KB
testcase_29 AC 596 ms
9,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

X = list(map(int, input()))
X.sort()
ans = [X.pop(0)]
while len(X):
    x = X.pop(0)
    if ans[-1] != x:
        ans += [x, ans.pop(0)]
        ans += X
        if ans[-1] != 0:
            print(''.join(map(str, reversed(ans))))
            break
    else:
        ans.append(x)
else:
    print(-1)
0