結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,148 KB
testcase_01 AC 3 ms
7,920 KB
testcase_02 AC 3 ms
7,996 KB
testcase_03 AC 3 ms
8,000 KB
testcase_04 AC 3 ms
8,032 KB
testcase_05 AC 3 ms
7,996 KB
testcase_06 AC 3 ms
8,012 KB
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

var l = Array(String(readLine()!)).sorted(by: >)
var n = 0
var s = Set(l)
if s.count < 2 || (s.count == 2 && l.contains("0")){
    print(-1)
}else{
    let m = Int(l.map{String($0)}.joined())!
    for i in [Int](1..<l.count).reversed(){
        (l[i-1],l[i]) = (l[i],l[i-1])
        n = Int(l.map{String($0)}.joined())!
        if m != n{
            break
        }
    }
    print(n)
}
0