結果
問題 |
No.707 書道
|
ユーザー |
![]() |
提出日時 | 2018-07-02 19:01:14 |
言語 | F# (F# 4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 871 bytes |
コンパイル時間 | 6,888 ms |
コンパイル使用メモリ | 195,752 KB |
実行使用メモリ | 32,768 KB |
最終ジャッジ日時 | 2024-07-01 01:33:49 |
合計ジャッジ時間 | 8,572 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 4 WA * 2 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (235 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/
ソースコード
let calCost sy sx (map : char[][]) = let cal y x = (sy - y) ** 2.0 + (sx - x) ** 2.0 |> sqrt let mutable cost = 0.0 for i in 1 .. map |> Array.length do for j in 1 .. map.[0] |> Array.length do if map.[i-1].[j-1] = '1' then cost <- cost + (cal (i |> float) (j |> float)) cost let H, W = let t = stdin.ReadLine().Split() |> Array.map int in t.[0], t.[1] let P = Array.init H (fun _ -> stdin.ReadLine().ToCharArray()) let mutable ans = 1 <<< 16 |> float for i in 1 .. H do ans <- min ans (calCost 0.0 (i |> float) P) ans <- min ans (calCost (W + 1 |> float) (i |> float) P) for i in 1 .. W do ans <- min ans (calCost (i |> float) 0.0 P) ans <- min ans (calCost (i |> float) (H + 1 |> float) P) ans |> printfn "%A"