結果
問題 | No.34 砂漠の行商人 |
ユーザー | Common Lisp |
提出日時 | 2024-11-15 03:53:21 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 1,883 bytes |
コンパイル時間 | 291 ms |
コンパイル使用メモリ | 41,976 KB |
実行使用メモリ | 34,788 KB |
最終ジャッジ日時 | 2024-11-15 03:53:23 |
合計ジャッジ時間 | 1,916 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
26,024 KB |
testcase_01 | AC | 10 ms
26,024 KB |
testcase_02 | AC | 11 ms
32,140 KB |
testcase_03 | AC | 10 ms
28,056 KB |
testcase_04 | AC | 12 ms
28,316 KB |
testcase_05 | AC | 13 ms
28,320 KB |
testcase_06 | AC | 13 ms
30,360 KB |
testcase_07 | AC | 17 ms
28,452 KB |
testcase_08 | AC | 18 ms
30,612 KB |
testcase_09 | AC | 16 ms
28,448 KB |
testcase_10 | AC | 15 ms
30,228 KB |
testcase_11 | AC | 16 ms
30,488 KB |
testcase_12 | AC | 12 ms
28,320 KB |
testcase_13 | AC | 25 ms
30,840 KB |
testcase_14 | AC | 27 ms
32,624 KB |
testcase_15 | AC | 12 ms
28,060 KB |
testcase_16 | AC | 14 ms
28,316 KB |
testcase_17 | AC | 12 ms
30,096 KB |
testcase_18 | AC | 11 ms
28,060 KB |
testcase_19 | AC | 17 ms
28,448 KB |
testcase_20 | AC | 21 ms
34,788 KB |
testcase_21 | AC | 14 ms
28,192 KB |
testcase_22 | AC | 12 ms
28,320 KB |
testcase_23 | AC | 12 ms
30,356 KB |
testcase_24 | AC | 21 ms
30,716 KB |
testcase_25 | AC | 13 ms
28,192 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 15 NOV 2024 03:53:21 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.027
ソースコード
(defparameter +dx+ (make-array 4 :element-type 'integer :initial-contents '(1 0 -1 0))) (defparameter +dy+ (make-array 4 :element-type 'integer :initial-contents '(0 -1 0 1))) (defvar *que* (make-array 1010101)) (defvar *que-front* 0) (defvar *que-back* 0) (defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (taro-hp (read)) (start-x (1- (read))) (start-y (1- (read))) (goal-x (1- (read))) (goal-y (1- (read))) (desert-levels (make-array (list n n) :element-type 'integer)) (dp1 (make-array (list n n) :element-type 'integer :initial-element 0)) (dp2 (make-array (list n n) :element-type 'integer :initial-element 0))) (dotimes (i n) (dotimes (j n) (setf (aref desert-levels i j) (read)))) (setf (aref dp1 start-y start-x) taro-hp) (setf (aref *que* *que-front*) (cons start-x start-y)) (incf *que-front*) (loop while (> *que-front* *que-back*) do (let* ((now (aref *que* *que-back*)) (x (car now)) (y (cdr now))) (incf *que-back*) (dotimes (k 4) (let ((xx (+ x (aref +dx+ k))) (yy (+ y (aref +dy+ k)))) (unless (or (or (< xx 0) (<= n xx) (< yy 0) (<= n yy)) (>= (aref dp1 yy xx) (- (aref dp1 y x) (aref desert-levels yy xx)))) (setf (aref dp1 yy xx) (- (aref dp1 y x) (aref desert-levels yy xx)) (aref dp2 yy xx) (1+ (aref dp2 y x)) (aref *que* *que-front*) (cons xx yy)) (incf *que-front*) (when (and (= xx goal-x) (= yy goal-y)) (format t "~d~%" (aref dp2 yy xx)) (return-from main 0))))))) (format t "-1~%")) 0) (main)