結果

問題 No.20 砂漠のオアシス
ユーザー A63635985A63635985
提出日時 2018-03-02 10:53:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,114 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 52,428 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-29 22:21:50
合計ジャッジ時間 2,121 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 15 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 92 ms
4,380 KB
testcase_09 AC 119 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 15 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 42 ms
4,376 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int N,V,field[201][201];
int dp[201][201];
int direction[5]={-1,0,1,0,-1};
struct Struct{
        int y,x;
};
Struct oasis;
bool recursion(int h,int w,int hp){
        if(h<0 || h>=N )return false;
        if(w<0 || w>=N )return false;
        hp-=field[h][w];
        if(h==oasis.y && w==oasis.x && oasis.x+oasis.y!=0 ){
                hp*=2;
                oasis.y=oasis.x=0;
        }
        if(hp<0)return false;
        if(h==N-1 && w==N-1 )return true;
        if(dp[h][w]>=hp)return false;
        dp[h][w]=hp;
        bool response=false;
        for(int i=0 ; i<4 ; i++ )
                response|=recursion(h+direction[i],w+direction[i+1],hp);
        return response;
}
int main(){
        cin >> N >> V;
        cin >> oasis.x >> oasis.y;
        for(int i=0 ; i<N ; i++ ){
                for(int j=0 ; j<N ; j++ ){
                        cin >> field[i][j];
                        dp[i][j]=-1;
                }
        }
        if(recursion(0,0,V))
                cout <<"YES"<<endl;
        else
                cout<<"NO"<<endl;
        return 0;
}
0