結果

問題 No.45 回転寿司
ユーザー mikan-watermikan-water
提出日時 2024-01-21 09:21:18
言語 Common Lisp
(sbcl 2.3.8)
結果
WA  
実行時間 -
コード長 1,694 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 39,424 KB
実行使用メモリ 29,728 KB
最終ジャッジ日時 2024-01-21 09:21:22
合計ジャッジ時間 2,858 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 9 ms
29,344 KB
testcase_23 AC 9 ms
29,344 KB
testcase_24 AC 9 ms
29,344 KB
testcase_25 AC 9 ms
29,344 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 10 ms
29,344 KB
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 21 JAN 2024 12:21:18 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

ソースコード

diff #

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