結果
問題 | No.123 カードシャッフル |
ユーザー |
![]() |
提出日時 | 2017-08-10 16:15:51 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 38 ms / 5,000 ms |
コード長 | 666 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 21,580 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-10-09 00:09:26 |
合計ジャッジ時間 | 988 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
let iota ?(start=0) ?(step=1) cnt =let rec doit i acc =if i <= 0 then accelse doit (i - 1) (start + step*(i - 1) :: acc) indoit cnt []let () =let n, m = Scanf.scanf "%d %d " (fun n m -> n, m) inlet l = iota ~start:1 n inlet rec doit i l =if i = m then lelselet a = Scanf.scanf "%d " (fun i -> i) inlet a = a - 1 inlet rec aux j xs = function| [] -> assert false| hd :: tl ->if j = a then hd :: List.rev_append xs tlelse aux (j + 1) (hd :: xs) tl inaux 0 [] l |> doit (i + 1) inmatch doit 0 l with| [] -> assert false| hd :: _ -> Printf.printf "%d\n" hd