結果
問題 | No.1359 [Zelkova 3rd Tune] 四人セゾン |
ユーザー | sansaqua |
提出日時 | 2021-01-22 21:42:34 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
AC
|
実行時間 | 471 ms / 2,000 ms |
コード長 | 6,317 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 93,220 KB |
実行使用メモリ | 32,284 KB |
最終ジャッジ日時 | 2023-08-27 18:18:07 |
合計ジャッジ時間 | 29,100 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
23,620 KB |
testcase_01 | AC | 9 ms
25,696 KB |
testcase_02 | AC | 9 ms
23,612 KB |
testcase_03 | AC | 236 ms
26,452 KB |
testcase_04 | AC | 237 ms
26,504 KB |
testcase_05 | AC | 221 ms
26,604 KB |
testcase_06 | AC | 221 ms
26,536 KB |
testcase_07 | AC | 325 ms
28,572 KB |
testcase_08 | AC | 328 ms
30,540 KB |
testcase_09 | AC | 93 ms
28,472 KB |
testcase_10 | AC | 93 ms
28,452 KB |
testcase_11 | AC | 417 ms
32,284 KB |
testcase_12 | AC | 416 ms
28,556 KB |
testcase_13 | AC | 267 ms
28,524 KB |
testcase_14 | AC | 266 ms
30,144 KB |
testcase_15 | AC | 235 ms
28,484 KB |
testcase_16 | AC | 236 ms
26,448 KB |
testcase_17 | AC | 439 ms
30,656 KB |
testcase_18 | AC | 442 ms
28,500 KB |
testcase_19 | AC | 383 ms
28,612 KB |
testcase_20 | AC | 380 ms
28,620 KB |
testcase_21 | AC | 411 ms
28,616 KB |
testcase_22 | AC | 413 ms
28,560 KB |
testcase_23 | AC | 283 ms
26,448 KB |
testcase_24 | AC | 282 ms
30,056 KB |
testcase_25 | AC | 49 ms
24,132 KB |
testcase_26 | AC | 49 ms
26,244 KB |
testcase_27 | AC | 149 ms
26,584 KB |
testcase_28 | AC | 147 ms
26,452 KB |
testcase_29 | AC | 179 ms
28,536 KB |
testcase_30 | AC | 179 ms
26,524 KB |
testcase_31 | AC | 240 ms
28,504 KB |
testcase_32 | AC | 241 ms
28,600 KB |
testcase_33 | AC | 178 ms
26,472 KB |
testcase_34 | AC | 178 ms
26,432 KB |
testcase_35 | AC | 235 ms
26,496 KB |
testcase_36 | AC | 236 ms
26,552 KB |
testcase_37 | AC | 51 ms
24,276 KB |
testcase_38 | AC | 51 ms
24,152 KB |
testcase_39 | AC | 44 ms
24,128 KB |
testcase_40 | AC | 43 ms
24,064 KB |
testcase_41 | AC | 87 ms
26,460 KB |
testcase_42 | AC | 87 ms
30,088 KB |
testcase_43 | AC | 71 ms
24,488 KB |
testcase_44 | AC | 439 ms
30,616 KB |
testcase_45 | AC | 185 ms
28,636 KB |
testcase_46 | AC | 66 ms
24,404 KB |
testcase_47 | AC | 309 ms
28,488 KB |
testcase_48 | AC | 295 ms
26,524 KB |
testcase_49 | AC | 299 ms
28,592 KB |
testcase_50 | AC | 229 ms
28,488 KB |
testcase_51 | AC | 19 ms
27,568 KB |
testcase_52 | AC | 393 ms
30,536 KB |
testcase_53 | AC | 452 ms
28,560 KB |
testcase_54 | AC | 464 ms
30,652 KB |
testcase_55 | AC | 464 ms
30,588 KB |
testcase_56 | AC | 467 ms
28,516 KB |
testcase_57 | AC | 471 ms
28,576 KB |
testcase_58 | AC | 469 ms
30,592 KB |
testcase_59 | AC | 466 ms
28,524 KB |
testcase_60 | AC | 459 ms
28,620 KB |
testcase_61 | AC | 447 ms
32,140 KB |
testcase_62 | AC | 464 ms
28,516 KB |
testcase_63 | AC | 466 ms
30,588 KB |
testcase_64 | AC | 464 ms
28,524 KB |
testcase_65 | AC | 463 ms
32,272 KB |
testcase_66 | AC | 460 ms
28,648 KB |
testcase_67 | AC | 471 ms
28,556 KB |
testcase_68 | AC | 457 ms
28,552 KB |
testcase_69 | AC | 442 ms
28,576 KB |
testcase_70 | AC | 443 ms
28,580 KB |
testcase_71 | AC | 433 ms
28,572 KB |
testcase_72 | AC | 467 ms
32,068 KB |
testcase_73 | AC | 461 ms
32,228 KB |
testcase_74 | AC | 457 ms
28,556 KB |
testcase_75 | AC | 459 ms
28,520 KB |
testcase_76 | AC | 456 ms
28,564 KB |
testcase_77 | AC | 458 ms
28,552 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 27 AUG 2023 06:17:36 PM): ; processing (IN-PACKAGE :CL-USER) ; processing (DEFPARAMETER *OPT* ...) ; processing (SET-DISPATCH-MACRO-CHARACTER #\# ...) ; processing (SETQ *RANDOM-STATE* ...) ; processing (DEFINE-INT-TYPES 2 ...) ; processing (DEFCONSTANT +MOD+ ...) ; processing (DEFMACRO DBG ...) ; processing (DECLAIM (INLINE PRINTLN)) ; processing (DEFUN PRINTLN ...) ; processing (DEFPACKAGE :CP/MOD-POWER ...) ; processing (IN-PACKAGE :CP/MOD-POWER) ; processing (DECLAIM (INLINE MOD-POWER)) ; processing (DEFUN MOD-POWER ...) ; processing (DEFPACKAGE :CP/READ-FIXNUM ...) ; processing (IN-PACKAGE :CP/READ-FIXNUM) ; processing (DECLAIM (FTYPE # ...)) ; processing (DEFUN READ-FIXNUM ...) ; processing (USE-PACKAGE :CP/READ-FIXNUM ...) ; processing (USE-PACKAGE :CP/MOD-POWER ...) ; processing (IN-PACKAGE :CL-USER) ; processing (DEFUN MAIN ...) ; processing (MAIN) ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.260
ソースコード
(in-package :cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defparameter *opt* #+swank '(optimize (speed 3) (safety 2)) #-swank '(optimize (speed 3) (safety 0) (debug 0))) #+swank (ql:quickload '(:cl-debug-print :fiveam :cp/util) :silent t) #+swank (use-package :cp/util :cl-user) #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) `(values ,(read s nil nil t)))) #+sbcl (setq *random-state* (seed-random-state (nth-value 1 (get-time-of-day))))) #-swank (eval-when (:compile-toplevel) (setq *break-on-signals* '(and warning (not style-warning)))) #+swank (set-dispatch-macro-character #\# #\> #'cl-debug-print:debug-print-reader) (macrolet ((def (b) `(progn (deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b)) (deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b)))) (define-int-types (&rest bits) `(progn ,@(mapcar (lambda (b) `(def ,b)) bits)))) (define-int-types 2 4 7 8 15 16 31 32 62 63 64)) (defconstant +mod+ 1000000007) (defmacro dbg (&rest forms) (declare (ignorable forms)) #+swank (if (= (length forms) 1) `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms)) `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))) (declaim (inline println)) (defun println (obj &optional (stream *standard-output*)) (let ((*read-default-float-format* (if (typep obj 'double-float) 'double-float *read-default-float-format*))) (prog1 (princ obj stream) (terpri stream)))) ;; BEGIN_INSERTED_CONTENTS (defpackage :cp/mod-power (:use :cl) (:export #:mod-power)) (in-package :cp/mod-power) (declaim (inline mod-power)) (defun mod-power (base power modulus) "Returns BASE^POWER mod MODULUS. Note: 0^0 = 1. BASE := integer POWER, MODULUS := non-negative fixnum" (declare ((integer 0 #.most-positive-fixnum) modulus power) (integer base)) (let ((base (mod base modulus)) (res (mod 1 modulus))) (declare ((integer 0 #.most-positive-fixnum) base res)) (loop while (> power 0) when (oddp power) do (setq res (mod (* res base) modulus)) do (setq base (mod (* base base) modulus) power (ash power -1))) res)) (defpackage :cp/read-fixnum (:use :cl) (:export #:read-fixnum)) (in-package :cp/read-fixnum) (declaim (ftype (function * (values fixnum &optional)) read-fixnum)) (defun read-fixnum (&optional (in *standard-input*)) "NOTE: cannot read -2^62" (macrolet ((%read-byte () `(the (unsigned-byte 8) #+swank (char-code (read-char in nil #\Nul)) #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil)))) (let* ((minus nil) (result (loop (let ((byte (%read-byte))) (cond ((<= 48 byte 57) (return (- byte 48))) ((zerop byte) ; #\Nul (error "Read EOF or #\Nul.")) ((= byte #.(char-code #\-)) (setq minus t))))))) (declare ((integer 0 #.most-positive-fixnum) result)) (loop (let* ((byte (%read-byte))) (if (<= 48 byte 57) (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result)))) (return (if minus (- result) result)))))))) ;; BEGIN_USE_PACKAGE (eval-when (:compile-toplevel :load-toplevel :execute) (use-package :cp/read-fixnum :cl-user)) (eval-when (:compile-toplevel :load-toplevel :execute) (use-package :cp/mod-power :cl-user)) (in-package :cl-user) ;;; ;;; Body ;;; (defun main () (declare (inline sort sb-impl::stable-sort-list)) (let* ((n (read)) (k (read)) (m (read)) (ps (make-array n :element-type 'uint31 :initial-element 0)) (es (make-array n :element-type 'uint31 :initial-element 0)) (as (make-array n :element-type 'uint31 :initial-element 0)) (hs (make-array n :element-type 'uint31 :initial-element 0))) (declare (uint31 n k m)) (dotimes (i n) (setf (aref ps i) (read-fixnum))) (dotimes (i n) (setf (aref es i) (read-fixnum))) (dotimes (i n) (setf (aref as i) (read-fixnum))) (dotimes (i n) (setf (aref hs i) (read-fixnum))) (setq ps (sort ps #'<) es (sort es #'<) as (sort as #'<) hs (sort hs #'<)) (dbg ps es as hs) (let ((scores (make-array n :element-type 'uint31 :initial-element 0))) (loop for i below n for p across ps for e across es for a across as for h across hs do (setf (aref scores i) (- (max p e a h) (min p e a h)))) (setq scores (sort scores #'>)) #>scores (let ((res 0)) (loop for d across scores do (incf res (mod-power d k m))) (println (mod res m)))))) #-swank (main) ;;; ;;; Test ;;; #+swank (progn (defparameter *lisp-file-pathname* (uiop:current-lisp-file-pathname)) (setq *default-pathname-defaults* (uiop:pathname-directory-pathname *lisp-file-pathname*)) (uiop:chdir *default-pathname-defaults*) (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *lisp-file-pathname*)) (defparameter *problem-url* "https://yukicoder.me/problems/no/1359")) #+swank (defun gen-dat () (uiop:with-output-file (out *dat-pathname* :if-exists :supersede) (format out ""))) #+swank (defun bench (&optional (out (make-broadcast-stream))) (time (run *dat-pathname* out))) #+(and sbcl (not swank)) (eval-when (:compile-toplevel) (when sb-c::*undefined-warnings* (error "undefined warnings: ~{~A~^ ~}" sb-c::*undefined-warnings*))) ;; To run: (5am:run! :sample) #+swank (5am:test :sample (5am:is (equal "45 " (run "2 2 100 1 1000 1002 2 3 1004 1006 4 " nil))) (5am:is (equal "625 " (run "1 4 10000 5 10 15 20 " nil))) (5am:is (equal "39598529 " (run "9 20210122 123456789 14 14 21 35 62 37 30 95 4 88 1 68 87 24 20 96 98 7 85 69 67 18 75 37 69 48 7 31 76 67 97 37 99 7 32 47 " nil))))