結果
問題 | No.3 ビットすごろく |
ユーザー | mikan-water |
提出日時 | 2024-01-18 09:19:42 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,402 bytes |
コンパイル時間 | 512 ms |
コンパイル使用メモリ | 37,572 KB |
実行使用メモリ | 33,332 KB |
最終ジャッジ日時 | 2024-09-28 03:14:59 |
合計ジャッジ時間 | 11,414 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
26,408 KB |
testcase_01 | AC | 9 ms
26,408 KB |
testcase_02 | AC | 11 ms
30,396 KB |
testcase_03 | AC | 54 ms
30,632 KB |
testcase_04 | WA | - |
testcase_05 | AC | 231 ms
26,920 KB |
testcase_06 | AC | 64 ms
26,796 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 215 ms
26,920 KB |
testcase_13 | AC | 43 ms
26,536 KB |
testcase_14 | AC | 504 ms
31,176 KB |
testcase_15 | AC | 775 ms
29,032 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 9 ms
26,408 KB |
testcase_22 | AC | 510 ms
31,184 KB |
testcase_23 | AC | 780 ms
31,196 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 10 ms
26,408 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 28 SEP 2024 03:14:47 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.118
ソースコード
;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Implement count system ;;;;;;;;;;;;;;;;;;;;;;;;;;; ; variables (defparameter *search_que* '(1)) (defparameter *history* '(1)) (defparameter *depth_list* '(1)) (defparameter *depth* 1) (defparameter *goal_depth_list* '()) (defvar *start* 1) ; functions (defun n_to_bit (node) (count #\1 (format nil "~b" node)) ) (defun add_node (node n) (cond ((or (> node n) (< node *start*) (> (count node *history*) 0)) (return-from add_node nil) )) (push node *search_que*) (push node *history*) (push *depth* *depth_list*) ) (defun add-neghboring-node (n now) ; next (add_node (+ now (n_to_bit now)) n) ; prev (add_node (- now (n_to_bit now)) n) ) ; add a present node to the que ; pop a node from que or return -1 ; return count if a node is the goal ; add neighboring node which isn't searched to the que (defun loop-count-goal (n) (loop (if (<= (length *search_que*) 0) (return-from loop-count-goal -1)) (if (= (car *search_que*) n) (push *depth* *goal_depth_list*)) ; (return-from loop-count-goal *depth*)) (setf *depth* (1+ (pop *depth_list*))) (add-neghboring-node n (pop *search_que*)) ) ) (defun n3 () (loop-count-goal (parse-integer (read-line))) (cond ((= (length *goal_depth_list*) 0) (princ -1)) (t (princ (loop for i in *goal_depth_list* minimize i)))) ) (n3)