結果
| 問題 | No.39 桁の数字を入れ替え |
| コンテスト | |
| ユーザー |
tak
|
| 提出日時 | 2019-07-04 15:32:09 |
| 言語 | F# (F# 10.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 44 ms / 5,000 ms |
| + 639µs | |
| コード長 | 1,188 bytes |
| 記録 | |
| コンパイル時間 | 5,244 ms |
| コンパイル使用メモリ | 225,000 KB |
| 実行使用メモリ | 33,432 KB |
| 最終ジャッジ日時 | 2026-08-30 18:47:01 |
| 合計ジャッジ時間 | 7,281 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (160 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
module Yuki
open System
open System.Text
let solve n =
let num2list n =
(string n).ToCharArray()
|> Array.map (string >> int)
|> Array.toList
let rec list2str (acc : StringBuilder) =
function
| [] -> acc.ToString()
| x :: xs -> list2str (acc.Append(string x)) xs
let rec f (acc : StringBuilder) xs =
match xs with
| [] -> acc.ToString()
| y :: ys ->
let xsMax = xs |> List.max
if y = xsMax then
f (acc.Append(string y)) ys
else
let swapRightIdx =
ys
|> List.indexed
|> List.findBack (fun (_, x) -> x = xsMax)
|> fun (idx, _) -> idx
let ys' =
ys
|> List.mapi (fun i v ->
match i with
| _ when i = swapRightIdx -> y
| _ -> v)
list2str (acc.Append(string ys.[swapRightIdx])) ys'
n
|> num2list
|> f (new StringBuilder())
let N = int <| Console.ReadLine()
solve N
|> Console.WriteLine
tak