結果
| 問題 | No.20 砂漠のオアシス | 
| コンテスト | |
| ユーザー |  goodbaton | 
| 提出日時 | 2015-07-29 19:20:17 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,257 bytes | 
| コンパイル時間 | 755 ms | 
| コンパイル使用メモリ | 80,128 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-13 05:20:47 | 
| 合計ジャッジ時間 | 1,481 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 WA * 11 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     scanf("%d%d%d%d",&n,&v,&ox,&oy);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:37:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |             scanf("%d",&l[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000003
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define SIZE 10000
int mo[5] = {0,1,0,-1,0};
int main(){
    int n,v,ox,oy,nowv,a,b;
    int l[210][210];
    bool visit_bf[210][210]={0},visit_oa[210][210]={0};
    
    scanf("%d%d%d%d",&n,&v,&ox,&oy);
    
    ox--;
    oy--;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&l[i][j]);
        }
    }
    
    priority_queue<pair<int,pair<int,int> > > pq,pq_oa;
    pq.push({v,{0,0}});
    visit_bf[0][0]=true;
    
    while(pq.size()){
        
        pair<int,pair<int,int> > p = pq.top();
        pq.pop();
        
        nowv = p.first;
        a = p.second.first;
        b = p.second.second;
        
        if(visit_bf[a][b]) continue;
        visit_bf[a][b] = true;
        
        if(nowv<=0) continue;
        
        if(b==ox && a==oy){
            pq_oa.push({nowv*2,{a,b}});
            visit_oa[a][b] = true;
        }
        
        if(a==n-1 && b==n-1){
            puts("YES");
            return 0;
        }
        
        for(int i=0;i<4;i++){
            
            if(a+mo[i]<0 || b+mo[i+1]<0 || n<=a+mo[i] || n<=b+mo[i+1]) continue;
            
            pq.push({nowv-l[a+mo[i]][b+mo[i+1]],{a+mo[i],b+mo[i+1]}});
        }
        
    }
    
    while(pq_oa.size()){
        
        pair<int,pair<int,int> > p = pq_oa.top();
        pq_oa.pop();
        
        nowv = p.first;
        a = p.second.first;
        b = p.second.second;
        
        if(visit_oa[a][b]) continue;
        visit_oa[a][b] = true;
        
        if(nowv<=0) continue;
        
        if(a==n-1 && b==n-1){
            puts("YES");
            return 0;
        }
        
        for(int i=0;i<4;i++){
            
            if(a+mo[i]<0 || b+mo[i+1]<0 || n<=a+mo[i] || n<=b+mo[i+1]) continue;
            
            pq_oa.push({nowv-l[a+mo[i]][b+mo[i+1]],{a+mo[i],b+mo[i+1]}});
        }
        
    }
    
    puts("NO");
    
    return 0;
}
            
            
            
        