結果
| 問題 |
No.20 砂漠のオアシス
|
| コンテスト | |
| ユーザー |
latte0119
|
| 提出日時 | 2015-05-02 13:34:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,179 bytes |
| コンパイル時間 | 1,335 ms |
| コンパイル使用メモリ | 163,620 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-13 05:10:06 |
| 合計ジャッジ時間 | 2,295 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
47 | scanf("%d%d%d%d",&N,&V,&oy,&ox);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:51:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | scanf("%d",&fld[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#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[200][200][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.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;
}
latte0119