Submission #2757075


Source Code Expand

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun a -> a in
  let bs = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun b -> b in
  List.map (fun a -> (true, a)) as_ @ List.map (fun b -> (false, b)) bs
  |> List.sort (fun (_, a) (_, b) -> compare a b)
  |> List.map fst
  |> (fun (b :: bs) ->
      List.fold_left (fun (b', (acc, curr)) b ->
        b,
        if b = b'
        then (acc, curr + 1)
        else (curr :: acc, 1)) (b, ([], 1)) bs)
  |> (fun (_, (acc, curr)) -> curr :: acc)
  |> (fun (n :: ns) ->
      List.fold_left (fun (b, (b', curr, acc)) n ->
        not b,
        if b = b'
        then (b', curr + n, acc)
        else if curr < n
        then (b, n - curr, acc * curr mod 1000000007)
        else (b', curr - n, acc * n mod 1000000007)) (true, (false, n, 1)) ns)
  |> (fun (_, (_, _, acc)) -> acc)
  |> Printf.printf "%d\n"

Submission Info

Submission Time
Task A - 1D Matching
User fetburner
Language OCaml (4.02.3)
Score 0
Code Size 973 Byte
Status WA
Exec Time 234 ms
Memory 33792 KB

Compile Error

File "./Main.ml", line 9, characters 5-182:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
File "./Main.ml", line 16, characters 5-305:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 3
WA × 11
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt WA 134 ms 19072 KB
001.txt WA 38 ms 8704 KB
002.txt WA 56 ms 11648 KB
003.txt WA 65 ms 13056 KB
004.txt WA 217 ms 27392 KB
005.txt WA 230 ms 33792 KB
006.txt WA 232 ms 33792 KB
007.txt WA 230 ms 33792 KB
008.txt WA 231 ms 33792 KB
009.txt WA 230 ms 33792 KB
010.txt WA 220 ms 33792 KB
011.txt AC 234 ms 33792 KB
example0.txt AC 1 ms 384 KB
example1.txt AC 1 ms 384 KB