結果

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

ソースコード

diff #
raw source code

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