結果
| 問題 |
No.2737 Compound Word
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-20 19:29:12 |
| 言語 | OCaml (5.2.1) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 484 bytes |
| コンパイル時間 | 1,956 ms |
| コンパイル使用メモリ | 22,128 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 17:20:18 |
| 合計ジャッジ時間 | 2,947 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
Scanf.scanf "%d" (fun n ->
let s = Array.init n (fun _ -> Scanf.scanf " %s" (fun s -> s)) in
let module S = Set.Make (struct type t = string let compare = compare end) in
let rec loop i set =
let rec loop2 j set =
if j >= n then loop (i + 1) set else
loop2 (j + 1) (if i = j then set else S.add (s.(i) ^ s.(j)) set)
in
if i = n then set else loop2 0 set
in
Printf.printf "%d\n" @@ S.cardinal @@ loop 0 S.empty
)