結果
| 問題 | No.20 砂漠のオアシス | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-05-12 19:31:27 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,073 bytes | 
| コンパイル時間 | 2,368 ms | 
| コンパイル使用メモリ | 213,892 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-05-12 19:31:31 | 
| 合計ジャッジ時間 | 3,800 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 17 WA * 4 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,V,ox,oy; cin >> N >> V >> ox >> oy;
    ox--; oy--;
    vector<vector<int>> L(N,vector<int>(N));
    for(auto &h : L) for(auto &w : h) cin >> w;
    vector dist(N,vector(N,vector(2,0)));
    dist.at(0).at(0).at(0) = V-L.at(0).at(0);
    priority_queue<tuple<int,int,int,int>> Q; Q.push({V-L.at(0).at(0),0,0,0});
    vector<pair<int,int>> dxy = {{-1,0},{0,1},{1,0},{0,-1}};
    while(Q.size()){
        auto [v,x,y,z] = Q.top(); Q.pop();
        if(dist.at(x).at(y).at(z) != v) continue;
        if(x == ox && y == oy && z == 0) z = 1,v *= 2;
        for(auto [dx,dy] : dxy){
            int nx = x+dx,ny = y+dy;
            if(min(nx,ny) < 0 || max(nx,ny) >= N) continue;
            int nv = v-L.at(nx).at(ny);
            if(dist.at(nx).at(ny).at(z) < nv) dist.at(nx).at(ny).at(z) = nv,Q.push({nv,nx,ny,z}); 
        }
    }
    if(dist.at(N-1).at(N-1).at(0) > 0 || dist.at(N-1).at(N-1).at(1) > 0) cout << "YES\n";
    else cout << "NO\n";
}
            
            
            
        