結果

問題 No.455 冬の大三角
ユーザー pekempey
提出日時 2017-01-27 19:48:56
言語 F#
(F# 4.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 12,255 ms
コンパイル使用メモリ 185,920 KB
実行使用メモリ 32,736 KB
最終ジャッジ日時 2024-06-29 22:44:04
合計ジャッジ時間 15,472 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (519 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 findPos (S : (char array) array) H W = 
    [for i in 0 .. H - 1 do for j in 0 .. W - 1 -> (i, j)]
    |> List.filter (fun (y, x) -> S.[y].[x] = '*')

let cross y1 x1 y2 x2 = y1 * x2 - y2 * x1

let isParallel y1 x1 y2 x2 y3 x3 = cross (y2 - y1) (x2 - x1) (y3 - y1) (x3 - x1) = 0
                
let H, W = System.Console.ReadLine().Split() |> Array.map int |> fun a -> a.[0], a.[1]
let S = [|for i in 1 .. H -> System.Console.ReadLine().ToCharArray()|]

let (y1, x1), (y2, x2) = findPos S H W |> Array.ofList |> fun a -> a.[0], a.[1]
let y3, x3 =
    [for i in 0 .. H - 1 do for j in 0 .. W - 1 -> (i, j)]
    |> List.filter (fun (y, x) -> not (isParallel y x y1 x1 y2 x2))
    |> List.head

S.[y3].[x3] <- '*'

S |> Array.iter (fun s -> s |> System.String.Concat |> System.Console.WriteLine)
0