Submission #1453497


Source Code Expand

let rec fold_tournament dir f = function
  | [x] -> x
  | xs ->
      List.fold_left (fun (acc, prev) x ->
        match prev with
        | None -> (acc, Some x)
        | Some y -> ((if dir then f y x else f x y) :: acc, None)) ([], None) xs
      |> (function
          | (acc, None) -> acc
          | (acc, Some x) -> x :: acc)
      |> fold_tournament (not dir) f
let fold_tournament f xs = fold_tournament true f xs

let () =
  let k = Scanf.scanf "%d\n" (fun k -> k) in
  let rs = Array.to_list @@ Array.init (1 lsl k) (fun _ ->
    Scanf.scanf "%d\n" (fun r -> r)) in
  List.map (fun r -> [(r, 1.)]) rs
    |> fold_tournament (fun rps rps' ->
        List.concat @@ List.map (fun (rps, rps') ->
          List.map (fun (r, p) ->
            List.map (fun (r', p') ->
              p' /. (1. +. 10. ** (float_of_int (r' - r) /. 400.))) rps'
            |> List.fold_left ( +. ) 0.
            |> ( *. ) p
            |> (fun p -> (r, p))) rps) [(rps, rps'); (rps', rps)])
    |> List.map snd
    |> List.iter (Printf.printf "%.10f\n")

Submission Info

Submission Time
Task C - トーナメント
User fetburner
Language OCaml (4.02.3)
Score 4
Code Size 1069 Byte
Status AC
Exec Time 91 ms
Memory 3200 KB

Judge Result

Set Name All
Score / Max Score 4 / 4
Status
AC × 6
Set Name Test Cases
All 00, 01, 02, 03, 90, 91
Case Name Status Exec Time Memory
00 AC 91 ms 3200 KB
01 AC 91 ms 3200 KB
02 AC 29 ms 3200 KB
03 AC 91 ms 3200 KB
90 AC 1 ms 384 KB
91 AC 1 ms 384 KB