Submission #4026602
Source Code Expand
(eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter OPT
#+swank '(optimize (speed 3) (safety 2))
#-swank '(optimize (speed 3) (safety 0) (debug 0)))
#+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
(shadow :run)
(use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
;; BEGIN_INSERTED_CONTENTS
(defmacro buffered-read-line (&optional (buffer-size 30) (in '*standard-input*) (terminate-char #\Space))
"Note that the returned string will be reused."
(let ((buffer (gensym))
(character (gensym))
(idx (gensym)))
`(let ((,buffer (load-time-value (make-string ,buffer-size
:element-type 'base-char))))
(declare (simple-base-string ,buffer))
(loop for ,character of-type base-char =
#-swank (code-char (read-byte ,in nil #\Newline))
#+swank (read-char ,in nil #\Newline)
for ,idx from 0
until (char= ,character #\Newline)
do (setf (schar ,buffer ,idx) ,character)
finally (setf (schar ,buffer ,idx) ,terminate-char)
(return (values ,buffer ,idx))))))
(defmacro split-ints-and-bind (vars string &body body)
(let ((pos1 (gensym "POS"))
(pos2 (gensym "POS"))
(str (gensym "STR")))
(labels ((expand (vars &optional (init-pos1 t))
(if (null vars)
body
`((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
(,pos2 (position #\space ,str :start ,pos1 :test #'char=))
(,(car vars) (parse-integer ,str :start ,pos1 :end ,pos2)))
,@(expand (cdr vars) nil))))))
`(let ((,str ,string))
(declare (string ,str))
,@(expand vars)))))
(defmacro define-int-types (&rest bits)
`(progn
,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)
(defmacro println (obj &optional (stream '*standard-output*))
`(let ((*read-default-float-format* 'double-float))
(prog1 (princ ,obj ,stream) (terpri ,stream))))
;; Hauptteil
(defun main ()
(let* ((n (read))
(m (read))
(mat (make-array (list n n) :element-type 'uint32 :initial-element #xffffffff)))
(dotimes (i m)
(split-ints-and-bind (a b cost) (buffered-read-line 15)
(setf (aref mat (- a 1) (- b 1)) cost
(aref mat (- b 1) (- a 1)) cost)))
(dotimes (i n)
(setf (aref mat i i) 0))
(dotimes (k n)
(dotimes (i n)
(do ((j (1+ i) (1+ j)))
((= j n))
(if (> (aref mat i j) (+ (aref mat i k) (aref mat k j)))
(setf (aref mat i j) (+ (aref mat i k) (aref mat k j))
(aref mat j i) (aref mat i j))))))
(println
(loop for i below n
minimize (loop for j below n
maximize (aref mat i j))))))
#-swank(main)
Submission Info
Submission Time |
|
Task |
D - バスと避けられない運命 |
User |
sansaqua |
Language |
Common Lisp (SBCL 1.1.14) |
Score |
100 |
Code Size |
3139 Byte |
Status |
AC |
Exec Time |
258 ms |
Memory |
28644 KB |
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
248 ms |
28644 KB |
sample_02.txt |
AC |
83 ms |
16868 KB |
sample_03.txt |
AC |
84 ms |
16864 KB |
test_01.txt |
AC |
84 ms |
16868 KB |
test_02.txt |
AC |
214 ms |
16864 KB |
test_03.txt |
AC |
258 ms |
16868 KB |
test_04.txt |
AC |
131 ms |
16864 KB |
test_05.txt |
AC |
139 ms |
16868 KB |
test_06.txt |
AC |
90 ms |
16864 KB |
test_07.txt |
AC |
213 ms |
16872 KB |
test_08.txt |
AC |
85 ms |
16864 KB |
test_09.txt |
AC |
124 ms |
16864 KB |
test_10.txt |
AC |
90 ms |
16868 KB |
test_11.txt |
AC |
90 ms |
16864 KB |
test_12.txt |
AC |
156 ms |
16868 KB |
test_13.txt |
AC |
90 ms |
16872 KB |
test_14.txt |
AC |
94 ms |
16868 KB |
test_15.txt |
AC |
203 ms |
16864 KB |
test_16.txt |
AC |
95 ms |
16868 KB |
test_17.txt |
AC |
129 ms |
16864 KB |
test_18.txt |
AC |
149 ms |
16868 KB |
test_19.txt |
AC |
96 ms |
16868 KB |
test_20.txt |
AC |
93 ms |
16868 KB |
test_21.txt |
AC |
83 ms |
16868 KB |
test_22.txt |
AC |
108 ms |
16872 KB |
test_23.txt |
AC |
83 ms |
16868 KB |
test_24.txt |
AC |
214 ms |
16868 KB |
test_25.txt |
AC |
214 ms |
16872 KB |
test_26.txt |
AC |
112 ms |
16864 KB |
test_27.txt |
AC |
121 ms |
16868 KB |
test_28.txt |
AC |
213 ms |
16868 KB |
test_29.txt |
AC |
214 ms |
16872 KB |
test_30.txt |
AC |
89 ms |
16872 KB |
test_31.txt |
AC |
84 ms |
16868 KB |
test_32.txt |
AC |
213 ms |
16868 KB |
test_33.txt |
AC |
214 ms |
16868 KB |
test_34.txt |
AC |
85 ms |
16864 KB |
test_35.txt |
AC |
106 ms |
16872 KB |
test_36.txt |
AC |
214 ms |
16868 KB |