結果
| 問題 | No.927 Second Permutation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-22 21:46:07 |
| 言語 | Python3 (3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 31 ms / 2,000 ms |
| + 592µs | |
| コード長 | 345 bytes |
| 記録 | |
| コンパイル時間 | 60 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 12,540 KB |
| 最終ジャッジ日時 | 2026-10-12 04:36:25 |
| 合計ジャッジ時間 | 2,308 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#!/usr/bin/env python3
def solve(x):
if len(x) == 1 or (x.count('0') == len(x) - 1) or (x.count(x[0]) == len(x)):
return -1
y = sorted(x, reverse=True)
for i in reversed(range(len(y) - 1)):
if y[i] != y[i + 1]:
y[i], y[i + 1] = y[i + 1], y[i]
break
return ''.join(y)
print(solve(input()))