結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2024-01-21 09:21:18 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,694 bytes |
| コンパイル時間 | 1,157 ms |
| コンパイル使用メモリ | 40,932 KB |
| 実行使用メモリ | 32,152 KB |
| 最終ジャッジ日時 | 2024-09-28 06:13:02 |
| 合計ジャッジ時間 | 2,743 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 WA * 29 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 28 SEP 2024 06:12:59 AM): ; file: /home/judge/data/code/Main.lisp ; in: DEFUN SELECT ; (PUSH (CADR (CAR SORTED)) *INDEX-LIST*) ; ==> ; (SETQ *INDEX-LIST* (CONS #:ITEM *INDEX-LIST*)) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*INDEX-LIST* ; (NEIGHBOR_P (CADR (CAR SORTED)) *INDEX-LIST*) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*INDEX-LIST* ; in: SETF *INDEX-LIST* ; (SETF *INDEX-LIST* NIL) ; ==> ; (SETQ *INDEX-LIST* NIL) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*INDEX-LIST* ; ; caught WARNING: ; 1 more use of undefined variable *INDEX-LIST* ; file: /home/judge/data/code/Main.lisp ; in: DEFUN INPUT-POINT ; (PUSH (PARSE-INTEGER (COERCE (REVERSE *N-STACK*) 'STRING)) *L-STACK*) ; ==> ; (SETQ *L-STACK* (CONS #:ITEM *L-STACK*)) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*L-STACK* ; in: DEFUN SEPARATE-N ; (PUSH (PARSE-INTEGER (COERCE (REVERSE *N-STACK*) 'STRING)) *L-STACK*) ; ==> ; (SETQ *L-STACK* (CONS #:ITEM *L-STACK*)) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*L-STACK* ; in: SETF *L-STACK* ; (SETF *L-STACK* NIL) ; ==> ; (SETQ *L-STACK* NIL) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*L-STACK* ; ; caught WARNING: ; 1 more use of undefined variable *L-STACK* ; file: /home/judge/data/code/Main.lisp ; in: DEFUN SEPARATE-N ; (SETF *N-STACK* 'NIL) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*N-STACK* ; (REVERSE *N-STACK*) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*N-STACK* ; in: SETF *N-STACK* ; (SETF *N-STACK* NIL) ; ==> ; (SETQ *N-STACK* NIL) ; ; caught WARNING: ; undefined variable: COMMON-LISP-USER::*N-STACK* ; ; caught WARNING: ; 3 more uses of undefined variable *N-STACK* ; file: /home/judge/data/code/Main.lisp ; in: DEFUN MAKE-V ; (REVERSE RET) ; ; caught WARNING: ; un
ソースコード
(setf *l-stack* nil)
(setf *n-stack* nil)
(setf *index-list* nil)
(defparameter *n* 7)
(defparameter *v* '((1 1)
(2 2)
(9 3)
(10 4)
(1 5)
(1 6)
(4 7)))
;functions
(defun separate-n (c)
(cond
((char= c #\ )
(push (parse-integer (coerce
(reverse *n-stack*)
'string))
*l-stack*)
(setf *n-stack* '()))
(t
(push c *n-stack*)))
)
(defun input-point (str)
(map nil #'separate-n str)
(push (parse-integer (coerce
(reverse *n-stack*)
'string))
*l-stack*)
(reverse *l-stack*)
)
(defun make-v (points)
(setf ret nil)
(loop for item in points
for i from 1 to 1000
do
(push (list item i) ret))
(reverse ret)
)
(defun sort-delicious (v)
(sort v #'(lambda (x y) (> (car x) (car y))))
)
(defun neighbor_p (index l)
(if (or
(> (count (1+ index) l) 0)
(> (count (1- index) l) 0))
t
nil)
)
(defun select (sorted n)
(cond
((or (= n 0) (equal nil sorted)) nil)
((neighbor_p (cadr (car sorted)) *index-list*)
(select (cdr sorted) n))
(t
(push (cadr (car sorted)) *index-list*)
(cons (car sorted) (select (cdr sorted) (1- n)))
)
)
)
(defun calc (l-2d)
(if (equal l-2d nil)
0
(+ (caar l-2d) (calc (cdr l-2d))))
)
(defun input ()
(setf *n* (parse-integer (read-line)))
(setf *v* (make-v (input-point (read-line))))
)
(defun p-log ()
(print *n*)
(print (ceiling *n* 2))
(print *v*)
(print (sort-delicious *v*))
(print (select (sort-delicious *v*) (ceiling *n* 2)))
(print *index-list*)
)
(defun n45 ()
(input)
;(p-log)
(princ (calc
(select
(sort-delicious *v*) (ceiling *n* 2))))
)
(n45)