結果

問題 No.20 砂漠のオアシス
ユーザー mino_yellowmino_yellow
提出日時 2022-11-20 23:15:50
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 635 bytes
コンパイル時間 4,326 ms
コンパイル使用メモリ 32,368 KB
実行使用メモリ 51,116 KB
最終ジャッジ日時 2023-10-21 18:31:36
合計ジャッジ時間 11,917 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
34,732 KB
testcase_01 AC 147 ms
51,116 KB
testcase_02 AC 46 ms
32,776 KB
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
fscanf(STDIN,"%d%d%d%d",$N,$V,$ox,$oy);
for($i=0;$i<$N;++$i) $m[] = array_map('intval',explode(" ", trim(fgets(STDIN))));

$memo = array_fill(0,$N,array_fill(0,$N,-1));
run(0,0,$V);
if($memo[$N-1][$N-1] > 0) echo "YES" . PHP_EOL;
else echo "NO" . PHP_EOL;

function run($y,$x,$now){
    global $m,$N,$ox,$oy,$memo;
    if($y==$oy && $x==$ox) $now *= 2;
    if($now<=0 || $now <= $memo[$y][$x]) return;
    $memo[$y][$x] = $now;

    if($y > 0) run($y-1,$x,$now-$m[$y-1][$x]);
    if($y < $N-1) run($y+1,$x,$now-$m[$y+1][$x]);
    if($x > 0) run($y,$x-1,$now-$m[$y][$x-1]);
    if($x < $N-1) run($y,$x+1,$now-$m[$y][$x+1]);
}


?>
0