結果

問題 No.249 N言っちゃダメゲーム (2)
ユーザー r6ever6eve
提出日時 2017-08-16 13:59:40
言語 OCaml
(5.1.0)
結果
RE  
実行時間 -
コード長 739 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:41:42
合計ジャッジ時間 924 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ss () = read_line () |> split_on_char ' '

  let read_ns () = read_ss () |> List.map int_of_string

end

let () =
  let rec doit i first_p s =
    if i = 1000 then s
    else
      match IO.read_ns () with
      | [n; k] ->
        let x = if k = n - 1 then 1 else 0 in
        doit (i + 1) (not first_p) (s + if first_p then x else 1 - x)
      | _ -> assert false in
  doit 0 true 0 |> Printf.printf "%d\n"
0