結果
問題 | No.927 Second Permutation |
ユーザー |
![]() |
提出日時 | 2019-12-01 20:34:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 522 bytes |
コンパイル時間 | 90 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-21 17:12:34 |
合計ジャッジ時間 | 2,438 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 RE * 21 |
ソースコード
x=int(input()) q=str(x) b=[] for i in range(len(q)): b.append(q[i]) b.sort(reverse=True) t=str() for i in range(len(q)): t+=str(b[i]) t=t[::-1] ans=str() cnt=0 cv=0 for i in range(0,len(t)-1): if t[i]!=t[i+1] and cnt==0 : cnt+=1 cv=i for j in range(0,len(t)): if j==cv: ans+=t[j+1] ans+=t[j] elif j==cv+1: continue else: ans+=t[j] ans=ans[::-1] if ans==ans[::-1]: print(-1) exit() if ans[0]=="0": print(-1) exit() print(ans)