結果
問題 | No.134 走れ!サブロー君 |
ユーザー | kuroi_13 |
提出日時 | 2017-03-27 12:05:38 |
言語 | Perl (5.38.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,316 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 5,216 KB |
実行使用メモリ | 26,168 KB |
最終ジャッジ日時 | 2023-09-20 17:12:58 |
合計ジャッジ時間 | 2,609 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
5,044 KB |
testcase_01 | AC | 6 ms
5,104 KB |
testcase_02 | AC | 5 ms
5,048 KB |
testcase_03 | AC | 11 ms
5,564 KB |
testcase_04 | AC | 20 ms
5,900 KB |
testcase_05 | AC | 40 ms
7,024 KB |
testcase_06 | AC | 91 ms
9,612 KB |
testcase_07 | WA | - |
testcase_08 | AC | 483 ms
26,056 KB |
testcase_09 | WA | - |
testcase_10 | AC | 5 ms
5,220 KB |
testcase_11 | AC | 5 ms
5,096 KB |
testcase_12 | AC | 5 ms
5,100 KB |
testcase_13 | AC | 5 ms
5,048 KB |
testcase_14 | AC | 5 ms
5,228 KB |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
use strict; use warnings; my @tmp = split(' ', <STDIN>); my %ini = (x => $tmp[0], y => $tmp[1]); my $n = <STDIN>; my $wgt = 0; my @des; for(1..$n){ @tmp = split(' ', <STDIN>); push @des, {x => $tmp[0], y => $tmp[1], w => $tmp[2]}; $wgt += $tmp[2]; } my $diff = 0; my $t = 0; my @dp; my $inf = 999999999; for my $i (0..(1<<$n)-1){ for my $j(0..$n-1){ $dp[$i][$j] = [$inf, 0]; } } for my $i (0..$n-1){ $diff = abs($des[$i]->{x} - $ini{x}) + abs($des[$i]->{y} - $ini{y}); $t = $diff * ($wgt + 100)/120 + $des[$i]->{w}; $dp[1<<$i][$i] = [$t, $wgt - $des[$i]->{w}]; } my $ni; my $val = 0; for my $i (1..(1<<$n)-1){ for my $j (0..$n-1){ next if($dp[$i][$j]->[0] == $inf); $wgt = $dp[$i][$j]->[1]; for my $k (0..$n-1){ next if(($i>>$k) % 2); $ni = $i | (1<<$k); $diff = abs($des[$k]->{x} - $des[$j]->{x}) + abs($des[$k]->{y} - $des[$j]->{y}); $t = $diff * ($wgt + 100)/120 + $des[$k]->{w}; if($dp[$i][$j]->[0] + $t < $dp[$ni][$k]->[0]){ $dp[$ni][$k] = [$dp[$i][$j]->[0] + $t, $wgt - $des[$k]->{w}]; } } } } my $ans = $inf; my $ai = 0; for(0..$n-1){ if($dp[(1<<$n)-1][$_][0] < $ans){ $ans = $dp[(1<<$n)-1][$_][0]; $ai = $_; } } $ans += (abs($des[$ai]->{x} - $ini{x}) + abs($des[$ai]->{y} - $ini{y}))*5/6; print $ans;