結果
問題 | 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 | NA let greeting_of_string = function | "nyanpass" -> NYANPASS | "-" -> NA | _ -> OTHER let array_forall f arr = Array.to_list arr |> List.for_all f let solve n arr = let rec solve' j result = if j >= n || (List.length result) > 1 then result else let isRentyon = array_forall (fun g -> g = NYANPASS || g = NA) arr.(j) in let nextResult = if isRentyon then j::result else result in solve' (j + 1) nextResult in let result = solve' 0 [] in match result with | j::[] -> j + 1 | _ -> -1 let read_matrix n = let arr = Array.make_matrix n n NA in let rec read_matrix' i = if (i < n) then ( let glst = read_line () |> Str.split (Str.regexp_string " ") |> List.map greeting_of_string in List.iteri (fun j g -> arr.(j).(i) <- g) glst; read_matrix' (i + 1) ) in read_matrix' 0; arr let () = let n = read_line () |> int_of_string in let arr = read_matrix n in solve n arr |> string_of_int |> print_endline