結果
問題 | No.239 にゃんぱすー |
ユーザー |
|
提出日時 | 2016-10-25 11:58:04 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 1,078 bytes |
コンパイル時間 | 388 ms |
コンパイル使用メモリ | 19,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 23:54:17 |
合計ジャッジ時間 | 1,937 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
type greeting = NYANPASS | OTHER | NAlet greeting_of_string =function | "nyanpass" -> NYANPASS | "-" -> NA | _ -> OTHERlet array_forall f arr = Array.to_list arr |> List.for_all flet solve n arr =let rec solve' j result =if j >= n || (List.length result) > 1 then resultelselet isRentyon =array_forall (fun g -> g = NYANPASS || g = NA) arr.(j)inlet nextResult = if isRentyon then j::result else resultinsolve' (j + 1) nextResultinlet result = solve' 0 [] inmatch result with| j::[] -> j + 1| _ -> -1let read_matrix n =let arr = Array.make_matrix n n NAinlet rec read_matrix' i =if (i < n) then (let glst = read_line () |>Str.split (Str.regexp_string " ") |>List.map greeting_of_stringinList.iteri (fun j g -> arr.(j).(i) <- g) glst;read_matrix' (i + 1))inread_matrix' 0;arrlet () =let n = read_line () |> int_of_string inlet arr = read_matrix n insolve n arr |> string_of_int |> print_endline