結果

問題 No.927 Second Permutation
ユーザー natoriusan
提出日時 2023-08-01 21:34:28
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 410 bytes
コンパイル時間 16,782 ms
コンパイル使用メモリ 183,912 KB
実行使用メモリ 43,648 KB
最終ジャッジ日時 2024-10-11 12:53:28
合計ジャッジ時間 22,311 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (322 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

let x = stdin.ReadLine () |> Seq.sortDescending |> Seq.map string |> String.concat ""

let s = Set.ofSeq x
if x.Length = 1 || s.Count = 1 || (s.Count = 2 && s.Contains '0') then
    "-1"
else
    let mutable index = x.Length - 2
    while x.[index] = x.[index+1] do
        index <- index - 1
    (if index = 0 then "" else x.[..index-1]) + string x.[index+1] + string x.[index] + x.[index+2..]
|> printfn "%s"
0