You are viewing a single comment's thread. Return to all comments →
This input is a bit tricky. My code may help F# folks.
open System let readList n parser = Seq.initInfinite (fun _ -> Console.ReadLine()) |> Seq.take n |> Seq.map parser |> Seq.toList let parseRelation (s: string) = match s.Split(' ') with | [|x|] -> int x, None | [|k; v|] -> int k, Some (int v) | _ -> failwith "OhGodWhy" let readTestCase () = let n = int <| Console.ReadLine() readList n parseRelation let isFunc relations = relations |> Map.ofList |> Map.toSeq |> Seq.length |> (=) (List.length relations) let boolStr = function | true -> "YES" | false -> "NO" [<EntryPoint>] let main args = let t = int <| Console.ReadLine() Seq.initInfinite (fun _ -> readTestCase ()) |> Seq.take t |> Seq.map isFunc |> Seq.map boolStr |> Seq.iter (printfn "%s") 0
Seems like cookies are disabled on this browser, please enable them to open this website
Functions or Not?
You are viewing a single comment's thread. Return to all comments →
This input is a bit tricky. My code may help F# folks.