結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2024-05-20 20:55:39 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 129 ms / 5,000 ms |
コード長 | 987 bytes |
コンパイル時間 | 12,784 ms |
コンパイル使用メモリ | 195,228 KB |
実行使用メモリ | 33,408 KB |
最終ジャッジ日時 | 2024-12-20 18:00:53 |
合計ジャッジ時間 | 17,015 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (647 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 permute =let rec loop1 x = function| [] -> [[x]]| (y :: ys) as xs -> (x :: xs) :: (List.map (fun x -> y :: x) (loop1 x ys))let rec loop2 = function| [] -> seq [List.empty]| x :: xs -> Seq.collect (loop1 x) (loop2 xs)loop2let multiplyZip arr1 arr2 = arr1 |> Seq.collect (fun x1 -> arr2 |> Seq.map (fun x2 -> (x1, x2)))// ----let _ = stdin.ReadLine() |> intlet a = stdin.ReadLine().Split() |> Seq.map int |> Seq.toListlet b = stdin.ReadLine().Split() |> Seq.map int |> Seq.toListlet pa = a |> permute // [[2; 4]; [4; 2]]let pb = b |> permute // [[1; 3]; [3; 1]]multiplyZip pa pb// [([2; 4], [1; 3]); ([2; 4], [3; 1]); ([4; 2], [1; 3]); ([4; 2], [3; 1])]|> Seq.map (fun (a, b) -> Seq.zip a b)// [[(2, 1); (4, 3)]; [(2, 3); (4, 1)]; [(4, 1); (2, 3)]; [(4, 3); (2, 1)]]|> Seq.map (Seq.sumBy (fun (a, b) -> if a > b then 1 else -1))// [2; 0; 0; 2]|> Seq.averageBy (fun x -> if x > 0 then 1. else 0.)// 0.5|> printfn "%A"