結果

問題 No.3 ビットすごろく
ユーザー mikan-watermikan-water
提出日時 2024-01-18 09:19:42
言語 Common Lisp
(sbcl 2.3.8)
結果
WA  
実行時間 -
コード長 1,402 bytes
コンパイル時間 1,098 ms
コンパイル使用メモリ 37,028 KB
実行使用メモリ 30,624 KB
最終ジャッジ日時 2024-01-18 09:19:54
合計ジャッジ時間 11,372 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
29,600 KB
testcase_01 AC 11 ms
29,600 KB
testcase_02 AC 10 ms
29,600 KB
testcase_03 AC 49 ms
29,984 KB
testcase_04 WA -
testcase_05 AC 198 ms
30,240 KB
testcase_06 AC 58 ms
29,984 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 187 ms
30,240 KB
testcase_13 AC 38 ms
29,856 KB
testcase_14 AC 431 ms
30,368 KB
testcase_15 AC 664 ms
30,624 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 10 ms
29,600 KB
testcase_22 AC 447 ms
30,368 KB
testcase_23 AC 676 ms
30,624 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 10 ms
29,600 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 18 JAN 2024 12:19:42 AM):

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.038

ソースコード

diff #

;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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)
0