Submission #223830


Source Code Expand

import tempfile, os, subprocess, sys
 
(_, file) = tempfile.mkstemp(suffix='.ml')
f = open(file, "w")
f.write("""
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 fold_lefti ~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
  ;;
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 ;;

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

module MI = Map.Make (struct
  type t = int 
  let compare = compare
end)

  
let solve n k arr =
  let rec iter i set =
    if i = n then ()
    else 
      let (m, id) = MI.max_binding set in
      if arr.(i) > m then begin pf "%d\n" id; iter (i + 1) set end
      else begin
        let set = MI.remove m set in
        let set = MI.add arr.(i) (i + 1) set in
        let (m, id) = MI.max_binding set in
        pf "%d\n" id; iter (i + 1) set
      end in
  let set = ref MI.empty in
  for i = 0 to k - 1 do
    set := MI.add arr.(i) (i + 1) !set
  done;
  let (_, i) = (MI.max_binding !set) in
  pf "%d\n" i;
  iter k !set
;;

let () =
  sf "%d %d " (fun n k ->
    let arr = Array.init n ~f:(fun _ -> sf "%d " (fun i -> i)) in
    solve n k arr)
;;
""")
f.close()
os.system("ocamlfind ocamlopt -linkpkg -package str,num,batteries -inline 20 -unsafe %s" % file)
os.system("./a.out")

Submission Info

Submission Time
Task B - 特別賞
User iab
Language Python (3.2.3)
Score 100
Code Size 1923 Byte
Status AC
Exec Time 874 ms
Memory 39228 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 40 / 40 60 / 60
Status
AC × 2
AC × 13
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
Subtask1 sample_01.txt, sample_02.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
Subtask2 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, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt
Case Name Status Exec Time Memory
sample_01.txt AC 677 ms 39228 KB
sample_02.txt AC 563 ms 38036 KB
subtask1_01.txt AC 563 ms 37944 KB
subtask1_02.txt AC 563 ms 37964 KB
subtask1_03.txt AC 579 ms 38016 KB
subtask1_04.txt AC 589 ms 37980 KB
subtask1_05.txt AC 579 ms 37956 KB
subtask1_06.txt AC 583 ms 38040 KB
subtask1_07.txt AC 585 ms 37980 KB
subtask1_08.txt AC 576 ms 37948 KB
subtask1_09.txt AC 684 ms 37976 KB
subtask1_10.txt AC 570 ms 37964 KB
subtask1_11.txt AC 569 ms 38016 KB
subtask2_01.txt AC 587 ms 37980 KB
subtask2_02.txt AC 566 ms 37972 KB
subtask2_03.txt AC 874 ms 38052 KB
subtask2_04.txt AC 694 ms 37960 KB
subtask2_05.txt AC 817 ms 38036 KB
subtask2_06.txt AC 687 ms 38044 KB
subtask2_07.txt AC 754 ms 38020 KB
subtask2_08.txt AC 685 ms 37980 KB
subtask2_09.txt AC 774 ms 38040 KB