結果
問題 | No.1 道のショートカット |
ユーザー | MiyamonY |
提出日時 | 2019-09-09 18:24:32 |
言語 | Scheme (Gauche-0.9.14) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,466 bytes |
コンパイル時間 | 234 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 31,688 KB |
最終ジャッジ日時 | 2024-07-08 05:16:24 |
合計ジャッジ時間 | 14,532 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
ソースコード
(use gauche.array) (use data.queue) (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 q (make-queue)) (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) (print graph) (array-set! times 1 0 0) (queue-push! q 1) (let loop () (unless (queue-empty? q) (let1 from (dequeue! q) (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))) (if (<= t (array-ref times to i)) (array-set! times to i t))))) (iota (+ c 1))) (unless (vector-ref visited to) (enqueue! q to) (vector-set! visited to #t))) (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))))