結果
| 問題 | 
                            No.3 ビットすごろく
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-01-18 09:19:42 | 
| 言語 | Common Lisp  (sbcl 2.5.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,402 bytes | 
| コンパイル時間 | 512 ms | 
| コンパイル使用メモリ | 37,572 KB | 
| 実行使用メモリ | 33,332 KB | 
| 最終ジャッジ日時 | 2024-09-28 03:14:59 | 
| 合計ジャッジ時間 | 11,414 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 WA * 19 | 
コンパイルメッセージ
; 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)