結果

問題 No.179 塗り分け
ユーザー mikan-watermikan-water
提出日時 2024-01-31 10:20:03
言語 Common Lisp
(sbcl 2.3.8)
結果
TLE  
実行時間 -
コード長 3,205 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 41,992 KB
実行使用メモリ 96,652 KB
最終ジャッジ日時 2024-01-31 10:20:10
合計ジャッジ時間 5,928 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
36,276 KB
testcase_01 AC 10 ms
29,472 KB
testcase_02 AC 10 ms
29,472 KB
testcase_03 AC 10 ms
29,472 KB
testcase_04 AC 10 ms
29,600 KB
testcase_05 AC 10 ms
29,600 KB
testcase_06 AC 135 ms
84,400 KB
testcase_07 AC 11 ms
29,600 KB
testcase_08 AC 10 ms
29,600 KB
testcase_09 AC 11 ms
29,600 KB
testcase_10 AC 280 ms
84,408 KB
testcase_11 AC 246 ms
84,408 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 31 JAN 2024 01:20:03 AM):

; file: /home/judge/data/code/Main.lisp
; in: DEFUN CREATE-P-MOVS
;     (MAPCAR #'- B INITIAL-CELL)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::INITIAL-CELL

;     (EQUAL INITIAL-CELL '(0 0))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::INITIAL-CELL

;     (SETF INITIAL-CELL (CAR *BLACKS*))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::INITIAL-CELL

; in: DEFUN CREATE-BLACKS
;     (SETF S (READ-LINE))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::S

; in: DEFUN INPUT-ROW-COL
;     (LOOP FOR C ACROSS S
;           DO (CONVERT-TO-INT C)
;           FINALLY (PUSH (PARSE-INTEGER (COERCE (REVERSE *STACK*) 'STRING))
;                         *INTS*))
; ==>
;   (LET ((C NIL) (#:LOOP-ACROSS-VECTOR-0 S) (#:LOOP-ACROSS-INDEX-1 0))
;     (DECLARE (IGNORABLE #:LOOP-ACROSS-INDEX-1)
;              (TYPE FIXNUM #:LOOP-ACROSS-INDEX-1)
;              (IGNORABLE #:LOOP-ACROSS-VECTOR-0)
;              (TYPE VECTOR #:LOOP-ACROSS-VECTOR-0)
;              (IGNORABLE C))
;     (LET ((#:LOOP-ACROSS-LIMIT-2 (LENGTH #:LOOP-ACROSS-VECTOR-0)))
;       (TAGBODY
;        SB-LOOP::NEXT-LOOP
;         (WHEN (>= #:LOOP-ACROSS-INDEX-1 #:LOOP-ACROSS-LIMIT-2)
;           (GO SB-LOOP::END-LOOP))
;         (SB-LOOP::LOOP-DESETQ C
;                               (AREF #:LOOP-ACROSS-VECTOR-0
;                                     #:LOOP-ACROSS-INDEX-1))
;         (SB-LOOP::LOOP-DESETQ #:LOOP-ACROSS-INDEX-1 (1+ #:LOOP-ACROSS-INDEX-1))
;         (CONVERT-TO-INT C)
;         (GO SB-LOOP::NEXT-LOOP)
;        SB-LOOP::END-LOOP
;         (PUSH (PARSE-INTEGER #) *INTS*))))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::S

;     (SETF S (READ-LINE))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::S

; 
; caught WARNING:
;   2 more uses of undefined variable S
; 
; compilation unit finished
;   Undefined variables:
;     INITIAL-

ソースコード

diff #

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Fix check-pmov
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; variables
; 2d-lists
(defparameter *row* 0)
(defparameter *col* 0)
(defparameter *map* nil)
(defparameter *p-movs* nil)
(defparameter *blacks* nil)
(defparameter *stack* nil)
(defparameter *ints* nil)
(defparameter *cells* nil)


; functions
(defun convert-to-int (c)
  (cond
    ((char= c #\ )
     (push (parse-integer
	     (coerce (reverse *stack*) 'string))
	   *ints*)
     (setf *stack* nil)
     )
    (t (push c *stack*))
    )
  )

(defun input-row-col ()
  (setf s (read-line))
  (loop for c across s
	do
	(convert-to-int c)
	finally
	(push (parse-integer
		(coerce (reverse *stack*) 'string))
	      *ints*)
	)
  (setf *ints* (reverse *ints*))
  (setf *row* (car *ints*))
  (setf *col* (cadr *ints*))
  )

(defun create-blacks ()
  ; Loop through the numbers the amount of
  ; times equal to the row.
  (loop for i from 0 to (1- *row*)
	do
	(setf s (read-line))
	(loop for c across s
	      for col from 0 to (1- (length s))
	      do
	      (if (equal #\# c)
		(push (list i col) *blacks*))
	      )
	)
  (setf *blacks* (reverse *blacks*))
  )

(defun create-p-movs ()
  (setf initial-cell (car *blacks*))
  (loop for b in *blacks*
	do
	(if (equal initial-cell '(0 0))
	  (setf *p-movs* *blacks*)
	  (push (mapcar #'- b initial-cell) *p-movs*)
	  )
	)
  ; Use the cdr of the list because
  ; the first element represents no move.
  (setf *p-movs* (cdr *p-movs*))
  )

(defun input ()
  (input-row-col)
  (create-blacks)
  )

; When a black cell exists at the place obtained
; by parallel translation,
; ERACE a present cell and the corresponding element from blacks.
; p-mov: (row column)
; now: (row column)
(defun b-check (p-mov now)
  (cond
    ; not black
    ((equal *cells*
	    (remove-if (lambda (l)
			 (equal l (mapcar #'+ p-mov now)))
		       *cells*))
     nil)
    ; now doesn't exist in blacks
    ((equal *cells*
	    (remove-if (lambda (l)
			 (equal l now))
		       *cells*))
     nil)
    (t
      ; erase now
     (setf *cells*
	   (remove-if (lambda (l)
			(equal l now))
		      *cells*))
     (setf *cells*
	   (remove-if (lambda (l)
			(equal l (mapcar #'+ p-mov now)))
		      *cells*))
     t)
    )
  )

(defun check-pmov (p-mov)
  ; Make a copy to use since
  ; the contents of the list will be changed.
  (setf *cells* *blacks*)
    (loop for now in *cells*
	  do
	  ; The current cell has already been erased.
	  (tagbody
	    (cond ((equal
		     *cells*
		     (remove-if (lambda (l) (equal l now))
				*cells*))
		   (go END))
		  )
	    (if (null (b-check p-mov now))
	      (return-from check-pmov nil))
	    (if (null *cells*)
	      (return-from check-pmov t))
	    END
	    )
	  )
  nil
  )

(defun color ()
  (input)
  ; initial check
  (cond
    ((or
       (oddp (length *blacks*))
       (> (length *blacks*) (* *row* *col*)))
     (princ 'NO)
     (return-from color))
    )

  (create-p-movs)

  ; Test by each p-mov
  (loop for p-mov in *p-movs*
        do
        (cond
          ((check-pmov p-mov)
           (princ 'YES)
           (return-from color)))
        )
  (princ 'NO)
  )

(defun n179 ()
  (color)
  )

(n179)
0