結果

問題 No.182 新規性の虜
ユーザー ichibanshibori
提出日時 2016-10-21 00:16:09
言語 OCaml
(5.2.1)
結果
AC  
実行時間 176 ms / 5,000 ms
コード長 584 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 19,896 KB
実行使用メモリ 22,780 KB
最終ジャッジ日時 2024-10-08 23:52:58
合計ジャッジ時間 3,224 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

module StrMap = Map.Make(String)

let solve alst =
  let rec solve' lst map =
    match lst with
    | [] -> map
    | x::xs ->
      let nextMap =
        if StrMap.mem x map then
          let cnt = StrMap.find x map in
          StrMap.add x (cnt + 1) map
        else
          StrMap.add x 1 map
      in
      solve' xs nextMap
  in
  solve' alst StrMap.empty |>
  StrMap.filter (fun k v -> v = 1) |>
  StrMap.cardinal

let () =
  let _ = read_line ()
  and alst = read_line () |>
             Str.split (Str.regexp_string " ")
  in
  solve alst |> print_int;
  print_newline ()
0