結果
問題 | No.927 Second Permutation |
ユーザー |
![]() |
提出日時 | 2020-11-08 15:37:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 71 ms / 2,000 ms |
コード長 | 487 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 65,408 KB |
最終ジャッジ日時 | 2024-07-22 15:08:37 |
合計ジャッジ時間 | 2,904 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) S=list(input()) N=len(S) # 1種類だとダメ S2=set(S) if len(S2)==1: print(-1) exit() # 最上位以外全部0だとダメ cnt=S.count("0") if cnt==N-1: print(-1) exit() # print(cnt) S.sort(reverse=True) for i in range(N-1,0,-1): if S[i]!=S[i-1]: S[i],S[i-1]=S[i-1],S[i] break print(''.join(map(str, S)))