結果

問題 No.48 ロボットの操縦
ユーザー mikan-watermikan-water
提出日時 2024-01-16 21:23:22
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 1,479 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 39,400 KB
実行使用メモリ 29,216 KB
最終ジャッジ日時 2024-01-16 21:23:24
合計ジャッジ時間 1,473 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
29,216 KB
testcase_01 AC 10 ms
29,216 KB
testcase_02 AC 10 ms
29,216 KB
testcase_03 AC 10 ms
29,216 KB
testcase_04 AC 10 ms
29,216 KB
testcase_05 AC 10 ms
29,216 KB
testcase_06 AC 10 ms
29,216 KB
testcase_07 AC 10 ms
29,216 KB
testcase_08 AC 10 ms
29,216 KB
testcase_09 AC 10 ms
29,216 KB
testcase_10 AC 10 ms
29,216 KB
testcase_11 AC 10 ms
29,216 KB
testcase_12 AC 10 ms
29,216 KB
testcase_13 AC 10 ms
29,216 KB
testcase_14 AC 10 ms
29,216 KB
testcase_15 AC 10 ms
29,216 KB
testcase_16 AC 11 ms
29,216 KB
testcase_17 AC 11 ms
29,216 KB
testcase_18 AC 11 ms
29,216 KB
testcase_19 AC 10 ms
29,216 KB
testcase_20 AC 10 ms
29,216 KB
testcase_21 AC 10 ms
29,216 KB
testcase_22 AC 11 ms
29,216 KB
testcase_23 AC 10 ms
29,216 KB
testcase_24 AC 10 ms
29,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 16 JAN 2024 12:23:22 PM):

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.080

ソースコード

diff #

; variables

; 0:N, 1:E, 2:S, 3:W
(defparameter *direction* 0)
(defparameter *x* 0)
(defparameter *y* 0)
(defparameter *k* 1)

(defvar *upper* (expt 10 9))
(defvar *lower* (* -1 (expt 10 9)))

;functions
(defun check_xyk ()
  (cond
    ((or
       (or (> *x* *upper*) (< *x* *lower*))
       (or (> *y* *upper*) (< *y* *lower*))
       (or (> *k* *upper*) (< *k* 1)))
     (print "NO"))
    (t (print "YES"))
    )
  )

(defun xy_quadrant (x y)
  (cond
    ((and (> x 0) (> y 0)) 1)
    ((and (< x 0) (> y 0)) 2)
    ((and (< x 0) (< y 0)) 3)
    ((and (> x 0) (< y 0)) 4)
    (t nil))
  )

(defun number_adv_1d (x k)
  (cond
    ((= x 0) 0)
    ((< (abs x) k) 1)
    ((= (mod x k) 0) (abs (/ x k)))
    (t (1+ (abs (truncate x k)))))
  )

(defun number_advance (x y k)
  (+ (number_adv_1d x k)
     (number_adv_1d y k))
  )

(defun number_rotate (x y quadrant)
  (cond
    ((= x 0)
     (if (> y 0)
       0
       2))
    ((= y 0) 1)
    (t
      (case quadrant
	(1 1)
	(2 1)
	(3 2)
	(4 2))
      ))
  )

(defun number_order (x y k quadrant)
  (+ (number_advance x y k)
     (number_rotate x y quadrant))
  )

(defun first_check (x y)
  (if (and (= x 0) (= y 0))
    t
    nil)
  )

(defun n48 ()
  (setf *x* (parse-integer (read-line)))
  (setf *y* (parse-integer (read-line)))
  (setf *k* (parse-integer (read-line)))

  (cond 
    ((first_check *x* *y*)
     (princ 0)
     (return-from n48 nil))
    )

  (princ (number_order *x* *y* *k* (xy_quadrant *x* *y*)))
  )

(n48)
0