結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2019-11-22 21:29:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 336 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 82,188 KB |
| 実行使用メモリ | 75,148 KB |
| 最終ジャッジ日時 | 2024-10-11 02:52:00 |
| 合計ジャッジ時間 | 3,166 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
from collections import Counter
x = input()
c = Counter(x)
if len(c.keys()) == 1:
print(-1)
exit()
ans = sorted(x, reverse=True)
for i in range(len(ans)-1, -1, -1):
if ans[i] != ans[i-1]:
ans[i], ans[i-1] = ans[i-1], ans[i]
break
if ans[0] == '0':
print(-1)
exit()
print(''.join(map(str, ans)))
tamato