結果

問題 No.20 砂漠のオアシス
ユーザー maimai
提出日時 2016-03-18 19:56:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,662 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 75,896 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2024-04-21 06:51:29
合計ジャッジ時間 7,020 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 30 ms
5,376 KB
testcase_05 AC 12 ms
5,376 KB
testcase_06 AC 23 ms
5,376 KB
testcase_07 AC 3,107 ms
18,688 KB
testcase_08 AC 167 ms
6,144 KB
testcase_09 AC 915 ms
12,288 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 13 ms
5,376 KB
testcase_14 AC 90 ms
5,632 KB
testcase_15 AC 41 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 135 ms
5,504 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <cstdio>
#include <cmath>

using namespace std;

int n,hp,ox,oy;
vector<vector<int>> map;

int foot[201][201][2];

int main(){
    int i,j,k;
    cin>>n>>hp>>ox>>oy;
    
    map.push_back(vector<int>());
    for (i=0;i<n;i++){
        map.push_back(vector<int>());
        vector<int> &v=map.back();
        v.push_back(999);
        for(j=0;j<n;j++){
            cin>>k;
            v.push_back(k);
        }
    }
    k=0;
    list<vector<int>> queue;
    queue.push_back(vector<int>{1,1,hp,0});
    for (;!queue.empty();queue.pop_front()){k++;
        vector<int> &v=queue.front();
        if (v[0]==n && v[1]==n){
            cout<<"YES"<<endl;
            return 0;
        }
        if (foot[v[0]][v[1]][v[3]]>=v[2]) continue;
        foot[v[0]][v[1]][v[3]]=v[2];
        
        v[2]-=map[v[0]][v[1]];
        if (v[2]<=0) continue;
        if (!v[3] && v[0]==ox && v[1]==oy){
            v[3]=1;
            v[2]*=2;
        }
        if (1<v[0]) if (foot[v[0]-1][v[1]][v[3]]<v[2]) 
            queue.push_back(vector<int>{v[0]-1,v[1],v[2],v[3]});
        if (1<v[1]) if (foot[v[0]][v[1]-1][v[3]]<v[2]) 
             queue.push_back(vector<int>{v[0],v[1]-1,v[2],v[3]});
        if (v[0]<n) if (foot[v[0]+1][v[1]][v[3]]<v[2]) 
             queue.push_back(vector<int>{v[0]+1,v[1],v[2],v[3]});
        if (v[1]<n) if (foot[v[0]][v[1]+1][v[3]]<v[2]) 
             queue.push_back(vector<int>{v[0],v[1]+1,v[2],v[3]});
        
        //queue.sort([](vector<int> &le,vector<int> &re){return le[0]+le[1]>re[0]+re[1];});
    }
    
    cout<<"NO"<<endl;
    
    return 0;
}
0