結果
問題 | No.792 真理関数をつくろう |
ユーザー | iwot |
提出日時 | 2020-09-12 14:37:50 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 1,423 bytes |
コンパイル時間 | 878 ms |
コンパイル使用メモリ | 35,268 KB |
実行使用メモリ | 35,412 KB |
最終ジャッジ日時 | 2024-06-10 11:40:05 |
合計ジャッジ時間 | 2,545 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
28,496 KB |
testcase_01 | AC | 10 ms
27,052 KB |
testcase_02 | AC | 8 ms
26,668 KB |
testcase_03 | AC | 13 ms
33,444 KB |
testcase_04 | AC | 8 ms
30,396 KB |
testcase_05 | AC | 11 ms
29,516 KB |
testcase_06 | AC | 22 ms
31,444 KB |
testcase_07 | AC | 10 ms
30,784 KB |
testcase_08 | AC | 10 ms
26,668 KB |
testcase_09 | AC | 9 ms
26,792 KB |
testcase_10 | AC | 9 ms
26,664 KB |
testcase_11 | AC | 8 ms
26,668 KB |
testcase_12 | AC | 9 ms
30,784 KB |
testcase_13 | AC | 8 ms
26,796 KB |
testcase_14 | AC | 9 ms
28,620 KB |
testcase_15 | AC | 8 ms
26,792 KB |
testcase_16 | AC | 14 ms
29,260 KB |
testcase_17 | AC | 10 ms
26,668 KB |
testcase_18 | AC | 9 ms
26,788 KB |
testcase_19 | AC | 8 ms
26,664 KB |
testcase_20 | AC | 12 ms
31,284 KB |
testcase_21 | AC | 34 ms
35,412 KB |
testcase_22 | AC | 8 ms
26,664 KB |
testcase_23 | AC | 9 ms
28,320 KB |
testcase_24 | AC | 9 ms
30,628 KB |
testcase_25 | AC | 8 ms
26,664 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 10 JUN 2024 11:40:03 AM): ; file: /home/judge/data/code/Main.lisp ; in: DEFUN SOLVE-LINES ; (DEFUN SOLVE-LINES (N LIMIT) ; (LET ((RESULT (MAKE-ARRAY LIMIT :INITIAL-ELEMENT NIL))) ; (DOTIMES (IDX LIMIT) (SETF # #)) ; RESULT)) ; --> SB-IMPL::%DEFUN SB-IMPL::%DEFUN SB-INT:NAMED-LAMBDA ; ==> ; #'(SB-INT:NAMED-LAMBDA SOLVE-LINES ; (N LIMIT) ; (DECLARE (SB-C::TOP-LEVEL-FORM)) ; (BLOCK SOLVE-LINES ; (LET ((RESULT #)) ; (DOTIMES (IDX LIMIT) (SETF #)) ; RESULT))) ; ; caught STYLE-WARNING: ; The variable N is defined but never used. ; ; compilation unit finished ; caught 1 STYLE-WARNING condition ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.048
ソースコード
(defun split-to-apply-fun-by-space (str num f &optional (result ())) (if (< num (length str)) (if (char= (char str num) #\Space) (split-to-apply-fun-by-space str (+ 1 num) f result) (split-to-apply-fun-by-space str (+ 1 num) f (cons (funcall f (+ 1 (length result)) (char str num)) result))) (reverse result))) (defun char-bool-to-p-str (num c) (if (char= #\0 c) (format nil "¬P_~A" num) (format nil "P_~A" num))) (defun solve-line (s) (if (char= #\0 (aref s (- (length s) 1))) nil (split-to-apply-fun-by-space (subseq s 0 (- (length s) 1)) 0 #'char-bool-to-p-str))) (defun join-by-AND (ss) (if (null ss) ss (format nil "(~{~A~^∧~})" ss))) (defun solve-lines (n limit) (let ((result (make-array limit :initial-element nil))) (dotimes (idx limit) (setf (aref result idx) (join-by-AND (solve-line (read-line))))) result)) (defun output-lines (ss) (loop for i from 0 until (>= i (length ss)) do (if (> i 0) (format t "∨")) (format t (aref ss i)))) (let* ((n (parse-integer (read-line))) (m (solve-lines n (expt 2 n))) (m2 (remove-if (lambda (x) (null x)) m))) (format t "A=") (if (= 0 (length m2)) (format t "⊥") (if (= (length m2) (expt 2 n)) (format t "⊤") (output-lines m2))) (format t "~%"))