(defun check (x y h w s) (let ((ss (make-array (list 101 101) :initial-element nil))) (dotimes (yy h) (dotimes (xx w) (unless (or (char= #\. (char (aref s yy) xx)) (aref ss yy xx)) (setf (aref ss yy xx) t) (let ((yyy (+ yy y)) (xxx (+ xx x))) (when (or (< yyy 0) (>= yyy h) (< xxx 0) (>= xxx w)) (return-from check nil)) (if (and (char= #\# (char (aref s yyy) xxx)) (not (aref ss yyy xxx))) (setf (aref ss yyy xxx) t) (return-from check nil)))))) (dotimes (yy h) (dotimes (xx w) (when (and (char= #\# (char (aref s yy) xx)) (not (aref ss yy xx))) (return-from check nil)))) t)) (defun main (&rest argv) (declare (ignorable argv)) (let* ((h (read)) (w (read)) (sharp-count 0) (s (make-array h :element-type 'string))) (dotimes (i h) (setf (aref s i) (read-line)) (dotimes (j w) (when (char= #\# (char (aref s i) j)) (incf sharp-count)))) (when (or (oddp sharp-count) (zerop sharp-count)) (format t "NO~%") (return-from main)) (loop for x from (- w) to w do (loop for y from (- h) to h when (check x y h w s) do (format t "YES~%") (return-from main))) (format t "NO~%"))) (main)