結果

問題 No.20 砂漠のオアシス
ユーザー latte0119latte0119
提出日時 2015-05-02 13:42:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 163,284 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 06:30:45
合計ジャッジ時間 2,703 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,376 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 19 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 21 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 5 ms
5,376 KB
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:48:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |     scanf("%d%d%d%d",&N,&V,&oy,&ox);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:52:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   52 |             scanf("%d",&fld[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

const int INF=1e9;
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};

struct data{
    int y,x,hp,f;
    data(int a,int b,int c,int d):
        y(a),x(b),hp(c),f(d){}
    data(){}
    bool operator<(const data &d)const{
        return hp<d.hp;
    }
};
int N,V,ox,oy,fld[256][256];

void solve(){
    int cost[256][256][2]={{{0}}};
    priority_queue<data>Q;
    Q.push(data(0,0,V,0));

    while(!Q.empty()){
        data d=Q.top();Q.pop();
        d.hp-=fld[d.y][d.x];
        if(d.hp<=0)continue;
        if((d.y==oy&&d.x==ox)&&d.f==0){
            d.f=1;
            d.hp*=2;
        }
        if(cost[d.y][d.x][d.f]>=d.hp)continue;
        cost[d.y][d.x][d.f]=d.hp;

        for(int i=0;i<4;i++){
            int ty=d.y+dy[i];
            int tx=d.x+dx[i];
            if(ty<0||ty>=N||tx<0||tx>=N)continue;
            Q.push(data(ty,tx,d.hp,d.f));
        }
    }

    int ma=max(cost[N-1][N-1][0],cost[N-1][N-1][1]);
    if(ma<=0)puts("NO");
    else puts("YES");
}
int main(){
    scanf("%d%d%d%d",&N,&V,&oy,&ox);
    oy--;ox--;
    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)
            scanf("%d",&fld[i][j]);

    solve();

    return 0;
}
0