結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
kou_kkk
|
| 提出日時 | 2025-10-02 12:33:45 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 437 bytes |
| コンパイル時間 | 3,604 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 12,056 KB |
| 最終ジャッジ日時 | 2025-10-02 12:33:57 |
| 合計ジャッジ時間 | 3,747 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 1 |
ソースコード
x = input()
sorted_x = sorted(x, reverse=True)
set1 = set()
for c in sorted_x:
if c == '0': continue
set1.add(c)
ans = '-1'
if len(set1) < 2:
print(ans)
exit()
for i in range(len(x)-1, 0, -1):
c1 = sorted_x[i]
c2 = sorted_x[i-1]
if c1 != c2:
list = sorted_x[:i-1]
list.append(c1)
list.append(c2)
list += sorted_x[i+1:]
break
ans = ''.join(list)
print(ans)
kou_kkk