結果
問題 | No.1 道のショートカット |
ユーザー | MiyamonY |
提出日時 | 2019-09-10 13:03:22 |
言語 | Scheme (Gauche-0.9.14) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,575 bytes |
コンパイル時間 | 82 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 28,672 KB |
最終ジャッジ日時 | 2024-07-08 05:17:23 |
合計ジャッジ時間 | 4,877 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 74 ms
27,520 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | AC | 73 ms
27,648 KB |
ソースコード
(use gauche.array) (use data.heap) (define (read-number) (string->number (read-line))) (define (read-numbers) (map string->number (string-split (read-line) #\space))) (let* ((n (read-number)) (c (read-number)) (v (read-number)) (s (read-numbers)) (t (read-numbers)) (y (read-numbers)) (m (read-numbers))) (define graph (make-vector (+ n 1) '())) (define visited (make-vector (+ n 1) #f)) (define times (make-array (shape 0 (+ n 1) 0 (+ c 1)) (ash 1 30))) (define heap (make-binary-heap :key cdr)) (for-each (lambda (x y z w) (vector-set! graph x (cons (cons y (cons z w)) (vector-ref graph x '())))) s t y m) (array-set! times 1 0 0) (binary-heap-push! heap (cons 1 0)) (let loop () (unless (binary-heap-empty? heap) (let* ((h (binary-heap-pop-min! heap)) (from (car h)) (weight (cdr h))) (vector-set! visited from #t) (let inner ((nodes (vector-ref graph from))) (unless (null? nodes) (let* ((node (car nodes)) (to (car node)) (cost (cadr node)) (time (cddr node))) (for-each (lambda (i) (if (>= (- i cost) 0) (let1 t (+ time (array-ref times from (- i cost))) (when (<= t (array-ref times to i)) (array-set! times to i t))))) (iota (+ c 1))) (unless (vector-ref! visited to) (binary-heap-push! heap (cons to (+ weight time))))) (inner (cdr nodes))))) (loop))) (let1 val (apply min (map (lambda (i) (array-ref times n i)) (iota (+ c 1)))) (print (if (= val (ash 1 30)) -1 val))))