結果

問題 No.20 砂漠のオアシス
ユーザー mino_yellowmino_yellow
提出日時 2022-11-20 23:27:53
言語 PHP
(8.3.4)
結果
TLE  
実行時間 -
コード長 734 bytes
コンパイル時間 6,014 ms
コンパイル使用メモリ 32,460 KB
実行使用メモリ 36,772 KB
最終ジャッジ日時 2023-10-21 18:39:43
合計ジャッジ時間 20,315 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
32,768 KB
testcase_01 AC 45 ms
32,768 KB
testcase_02 AC 45 ms
32,768 KB
testcase_03 AC 60 ms
32,768 KB
testcase_04 AC 139 ms
32,768 KB
testcase_05 AC 79 ms
36,772 KB
testcase_06 AC 161 ms
34,660 KB
testcase_07 TLE -
testcase_08 AC 1,359 ms
34,660 KB
testcase_09 AC 2,565 ms
34,660 KB
testcase_10 AC 45 ms
32,768 KB
testcase_11 AC 44 ms
32,768 KB
testcase_12 AC 80 ms
32,768 KB
testcase_13 AC 126 ms
32,768 KB
testcase_14 AC 384 ms
32,768 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 260 ms
32,768 KB
testcase_18 WA -
testcase_19 AC 710 ms
32,768 KB
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
fscanf(STDIN,"%d%d%d%d",$N,$V,$ox,$oy);
--$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,1);

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

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

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


?>
0