結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
sash2104
|
| 提出日時 | 2019-11-22 21:45:48 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 562 bytes |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 12,908 KB |
| 最終ジャッジ日時 | 2024-10-11 03:13:01 |
| 合計ジャッジ時間 | 2,779 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#!/usr/bin/env python
# coding: utf-8
def ri():
return int(input())
def rl():
return list(input().split())
def rli():
return list(map(int, input().split()))
def solve(x):
last = x[-1]
for i in range(len(x)-2, -1, -1):
if x[i] == last:
continue
if i == 0 and last == '0':
return -1
return "".join(x[:i]+[x[i+1]]+[x[i]]+x[i+2:])
return -1
def main():
x = list(input())
x.sort(reverse=True)
# print(x)
ans = solve(x)
print(ans)
if __name__ == '__main__':
main()
sash2104