結果

問題 No.927 Second Permutation
ユーザー MaboyMaboy
提出日時 2021-06-28 05:55:47
言語 Swift
(5.10.0)
結果
WA  
実行時間 -
コード長 275 bytes
コンパイル時間 1,209 ms
コンパイル使用メモリ 116,744 KB
実行使用メモリ 13,292 KB
最終ジャッジ日時 2023-09-07 18:12:50
合計ジャッジ時間 2,961 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,688 KB
testcase_01 AC 3 ms
8,028 KB
testcase_02 AC 3 ms
7,800 KB
testcase_03 AC 3 ms
7,796 KB
testcase_04 AC 3 ms
7,956 KB
testcase_05 AC 4 ms
7,784 KB
testcase_06 AC 3 ms
7,856 KB
testcase_07 AC 3 ms
7,992 KB
testcase_08 AC 14 ms
9,028 KB
testcase_09 AC 4 ms
7,800 KB
testcase_10 AC 21 ms
9,576 KB
testcase_11 AC 32 ms
10,896 KB
testcase_12 AC 17 ms
9,116 KB
testcase_13 AC 6 ms
8,188 KB
testcase_14 AC 22 ms
9,812 KB
testcase_15 AC 16 ms
9,124 KB
testcase_16 AC 36 ms
13,292 KB
testcase_17 AC 36 ms
13,124 KB
testcase_18 AC 35 ms
13,188 KB
testcase_19 AC 36 ms
13,056 KB
testcase_20 AC 36 ms
13,056 KB
testcase_21 AC 36 ms
13,208 KB
testcase_22 AC 37 ms
13,224 KB
testcase_23 AC 36 ms
13,196 KB
testcase_24 AC 15 ms
10,180 KB
testcase_25 AC 12 ms
9,088 KB
testcase_26 AC 9 ms
8,796 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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