Submission #286805


Source Code Expand

let pf = Printf.printf ;;
let epf = Printf.eprintf ;;
let sf = Scanf.scanf ;;

let (|>) x f = f x ;;
let (@@) f x = f x ;;

module Array = struct
  include ArrayLabels
  let foldi ~f ~init arr =
    let acc = ref init in
    for i = 0 to Array.length arr - 1 do
      acc := f i !acc arr.(i)
    done;
    !acc
  ;;

  let findi arr ~f =
    let len = Array.length arr in
    let rec iter i =
      if i = len then None
      else if f arr.(i) then Some i
      else iter (i + 1) in
    iter 0
  ;;

  let findi_exn arr ~f =
    let len = Array.length arr in
    let rec iter i =
      if i = len then None
      else if f arr.(i) then Some i
      else iter (i + 1) in
    iter 0
  ;;

  (* i ∈ [0..res) -> not (f i) /\ i ∈ [res, len) -> f i *)
  let lower_bound arr ~f =
    let l, h = 0, Array.length arr in
    (* res ∈ (l, h] *)
    let rec iter l h =
      if l = h - 1 then h
      else 
        let m = (l + h) lsr 1 in
        if f m then iter l m
        else iter m h in
    iter l h
  ;;

  (* i ∈ [0..res] -> f i /\ i ∈ (res, len) -> not (f i) *)
  let upper_bound arr ~f =
    let l, h = 0, Array.length arr in
    (* res ∈ [l, h) *)
    let rec iter l h =
      if l = h - 1 then l
      else 
        let m = (l + h) lsr 1 in
        if f m then iter m h
        else iter l m in
    iter l h
  ;;
end
  
module String = StringLabels ;;
module List  = struct
  include ListLabels ;;
  let rec repeat n a = if n = 0 then [] else a :: repeat (n - 1) a ;;
  let rec drop n a =
    if n = 0 then a
    else match a with
    | [] -> failwith "cannot take"
    | x :: xs -> drop (n - 1) xs ;;

  let init ~f n =
    let res = ref [] in
    for i = 0 to n - 1 do
      res := f i :: !res
    done;
    List.rev !res
  ;;
end ;;
module H = Hashtbl ;;

let c = ref ' ' ;;
let is_num c = '0' <= c && c <= '9' ;;
let is_space c = c = ' ' || c = '\n' || c = '\t' ;;
let to_num c = Char.code c - Char.code '0' ;;
let read_char () = input_char stdin ;;

let next_int () =
  while is_space !c do
    c := read_char () ;
  done;
  let ok = ref false in
  let acc = ref 0 in
  while is_num !c do
    ok := true;
    acc := !acc * 10 + to_num !c;
    c := read_char ();
  done;
  if !ok then !acc
  else raise (Failure "next_int")
;; 

module SI = Set.Make (struct
  type t = int 
  let compare = compare
end)

let solve n k =
  let rec iter n k =
    if k == 0 || n == 1 && k == 1 then pf "YES\n"
    else if n == 0 then pf "NO\n"
    else iter (n - 2) (k - 1) in
  iter n k
;;

let () =
  sf "%d %d " (fun n k ->
    let n = n - 1 in
    solve n k)
;;

Submission Info

Submission Time
Task A - 閉路グラフ
User iab
Language OCaml (3.12.1)
Score 0
Code Size 2685 Byte
Status WA
Exec Time 39 ms
Memory 1172 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 4
AC × 25
WA × 5
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask1_26.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 29 ms 1124 KB
subtask0_sample_02.txt AC 28 ms 1152 KB
subtask0_sample_03.txt AC 31 ms 1132 KB
subtask0_sample_04.txt AC 38 ms 1172 KB
subtask1_01.txt AC 39 ms 1020 KB
subtask1_02.txt AC 31 ms 1148 KB
subtask1_03.txt AC 27 ms 1124 KB
subtask1_04.txt AC 31 ms 1148 KB
subtask1_05.txt AC 31 ms 1024 KB
subtask1_06.txt WA 31 ms 1028 KB
subtask1_07.txt WA 28 ms 1152 KB
subtask1_08.txt AC 28 ms 1152 KB
subtask1_09.txt AC 31 ms 1024 KB
subtask1_10.txt AC 28 ms 1128 KB
subtask1_11.txt AC 29 ms 1148 KB
subtask1_12.txt AC 26 ms 1144 KB
subtask1_13.txt AC 29 ms 1036 KB
subtask1_14.txt WA 29 ms 1024 KB
subtask1_15.txt WA 32 ms 1024 KB
subtask1_16.txt AC 29 ms 1148 KB
subtask1_17.txt AC 31 ms 1148 KB
subtask1_18.txt AC 30 ms 1100 KB
subtask1_19.txt AC 30 ms 1064 KB
subtask1_20.txt AC 31 ms 1148 KB
subtask1_21.txt AC 29 ms 1148 KB
subtask1_22.txt WA 31 ms 1148 KB
subtask1_23.txt AC 32 ms 1164 KB
subtask1_24.txt AC 31 ms 1112 KB
subtask1_25.txt AC 25 ms 1136 KB
subtask1_26.txt AC 28 ms 1144 KB