結果

問題 No.927 Second Permutation
ユーザー 👑 H20H20
提出日時 2021-11-03 01:57:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 72,244 KB
最終ジャッジ日時 2024-04-20 14:25:12
合計ジャッジ時間 2,542 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
54,784 KB
testcase_01 AC 40 ms
55,228 KB
testcase_02 AC 41 ms
53,912 KB
testcase_03 AC 41 ms
54,856 KB
testcase_04 AC 40 ms
53,620 KB
testcase_05 AC 41 ms
54,504 KB
testcase_06 AC 40 ms
54,868 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 53 ms
70,252 KB
testcase_25 AC 49 ms
66,528 KB
testcase_26 AC 49 ms
64,788 KB
testcase_27 AC 46 ms
63,644 KB
testcase_28 AC 51 ms
70,228 KB
testcase_29 AC 49 ms
67,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
X = list(input())
C = collections.Counter(X)
if len(C)==1:
    print(-1)
    exit()
cnt = 0
for k,v in C.items():
    if k!='0':
        cnt+=v
if cnt==1:
    print(-1)
    exit()
for i in range(0,10):
    for j in range(i+1,10):
        if C[str(i)] and C[str(j)]:
            ans = ''
            for k in reversed(range(10)):
                ans+=str(k)*(C[str(k)]-int(k==j))
                if k==i:
                    ans+=str(j)
            print(ans)
            exit()
0