結果
問題 | No.2792 Security Cameras on Young Diagram |
ユーザー | Lisp_Coder |
提出日時 | 2024-06-22 17:35:32 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 1,367 bytes |
コンパイル時間 | 960 ms |
コンパイル使用メモリ | 30,720 KB |
実行使用メモリ | 27,264 KB |
最終ジャッジ日時 | 2024-06-24 18:48:43 |
合計ジャッジ時間 | 2,260 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
21,888 KB |
testcase_01 | AC | 8 ms
21,888 KB |
testcase_02 | AC | 8 ms
21,888 KB |
testcase_03 | AC | 8 ms
21,760 KB |
testcase_04 | AC | 8 ms
21,760 KB |
testcase_05 | AC | 8 ms
21,888 KB |
testcase_06 | AC | 8 ms
21,888 KB |
testcase_07 | AC | 8 ms
21,760 KB |
testcase_08 | AC | 9 ms
21,888 KB |
testcase_09 | AC | 8 ms
21,888 KB |
testcase_10 | AC | 8 ms
21,888 KB |
testcase_11 | AC | 9 ms
21,888 KB |
testcase_12 | AC | 47 ms
25,600 KB |
testcase_13 | AC | 33 ms
24,576 KB |
testcase_14 | AC | 45 ms
25,216 KB |
testcase_15 | AC | 24 ms
24,192 KB |
testcase_16 | AC | 48 ms
25,600 KB |
testcase_17 | AC | 60 ms
26,368 KB |
testcase_18 | AC | 20 ms
23,936 KB |
testcase_19 | AC | 20 ms
23,936 KB |
testcase_20 | AC | 29 ms
24,448 KB |
testcase_21 | AC | 8 ms
21,888 KB |
testcase_22 | AC | 10 ms
21,888 KB |
testcase_23 | AC | 77 ms
27,264 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 24 JUN 2024 06:48:40 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.038
ソースコード
(defun mod-inverse (a m) (let ((m0 m) (y 0) (x 1)) (if (= m 1) 0 (progn (loop while (> a 1) do (let ((q (floor a m)) (temp m)) (setf m (mod a m) a temp) (setf temp y y (- x (* q y)) x temp))) (if (< x 0) (+ x m0) x))))) (defun comb-lut (N MOD) (let ((F (make-array (1+ N) :initial-element 1)) (InvF (make-array (1+ N) :initial-element 1))) (loop for i from 1 to N do (setf (aref F i) (mod (* (aref F (1- i)) i) MOD))) (setf (aref InvF N) (mod-inverse (aref F N) MOD)) (loop for i from (1- N) downto 0 do (setf (aref InvF i) (mod (* (aref InvF (1+ i)) (1+ i)) MOD))) (lambda (n r) (assert (and (<= 0 n N) (<= 0 r))) (if (<= 0 r n) (mod (* (mod (* (aref F n) (aref InvF r)) MOD) (aref InvF (- n r))) MOD) 0)))) (defun main () (let* ((MOD 998244353) (N (read)) (A (loop for i from 1 to N collect (read))) (comb (comb-lut (+ N (apply #'max A)) MOD)) (ans 1)) (loop for q from 1 to N for a in A do (setf ans (mod (+ ans (funcall comb (+ q a -1) q)) MOD))) (princ ans)(terpri))) (main)