結果

問題 No.927 Second Permutation
コンテスト
ユーザー Maboy
提出日時 2021-06-28 05:55:47
言語 Swift
(6.2.4)
コンパイル:
swiftc _filename_ -Ounchecked -o a.out
実行:
./a.out
結果
WA  
実行時間 -
コード長 275 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 846 ms
コンパイル使用メモリ 143,464 KB
実行使用メモリ 15,464 KB
最終ジャッジ日時 2026-03-11 20:35:05
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

var l = Array(String(readLine()!)).sorted(by: >)
var s = Set(l)
if s.count < 2 || (l.count == 2 && l.contains("0")){
    print(-1)
}else{
    let e = l[l.count - 1]
    let f = l.firstIndex(of: e)!
    (l[f - 1],l[f]) = (l[f],l[f - 1])
    print(l.map{String($0)}.joined())
}
0