結果

問題 No.3786 Four Triplets, One Pair
コンテスト
ユーザー ta-eo
提出日時 2026-11-30 23:16:52
言語 OCaml
(5.5.2)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 734µs
コード長 508 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 300 ms
コンパイル使用メモリ 22,872 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-11-30 23:16:55
合計ジャッジ時間 2,108 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

diff #
raw source code

open Scanf
open Printf

let solve aa =
  let t = Array.make 11 0 in
  let _ = Array.fold_left (fun _ a -> t.(a) <- t.(a) + 1) () aa in
  match
    Array.fold_left
      (fun (acc, i) cnt -> (if cnt < 1 || cnt = 3 then acc else (i, cnt) :: acc), i + 1) 
      ([], 0) t
    |> fst
  with
  | (i, 1) :: [] -> "1\n" ^ string_of_int i
  | (i, 2) :: (j, 2) :: [] -> sprintf "2\n%d %d" j i
  | _ -> "0\n"

let () =
  let a = Array.init 13 (fun _ -> scanf " %d" Fun.id) in
  let ans = solve a in
  printf "%s\n" ans
0