結果
問題 |
No.20 砂漠のオアシス
|
ユーザー |
![]() |
提出日時 | 2016-04-02 19:05:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,868 bytes |
コンパイル時間 | 700 ms |
コンパイル使用メモリ | 72,092 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 05:36:15 |
合計ジャッジ時間 | 1,522 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 5 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <set> #include <map> #include <queue> #include <climits> #include <cassert> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) #define INF INT_MAX/3 #define LINF LLONG_MAX/3 #define MP make_pair #define PB push_back #define ALL(v) (v).begin(),(v).end() typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; struct node{ int x,y,HP; bool used; }; const int dx[4]={1,0,-1,0}; const int dy[4]={0,1,0,-1}; int N,V,Ox,Oy; int L[201][201]; int tbl[201][201][2]; bool in_field(int x,int y){ if(x<0 or y<0 or x>=N or y>=N) return false; else return true; } int main(){ cin >> N >> V >> Ox >> Oy; Ox--; Oy--; REP(i,N) REP(j,N) REP(k,2) tbl[i][j][k] = 0; REP(i,N) REP(j,N) cin >> L[i][j]; queue<node> que; que.push(node{0,0,V,false}); while(!que.empty()){ node p = que.front(); que.pop(); if(p.x==N-1 and p.y==N-1){ cout << "YES" << endl; return 0; } if(tbl[p.x][p.y][p.used]>p.HP) continue; for(int i=0;i<4;i++){ int nx = p.x + dx[i]; int ny = p.y + dy[i]; if(!in_field(nx,ny)) continue; if(p.HP-L[nx][ny]<=0) continue; if(nx==Ox && ny==Oy && p.used==false){ if(tbl[nx][ny][1]<(p.HP-L[nx][ny])*2){ tbl[nx][ny][1] = (p.HP-L[nx][ny])*2; que.push(node{nx,ny,tbl[nx][ny][1],true}); } }else{ if(tbl[nx][ny][p.used]<p.HP-L[nx][ny]){ tbl[nx][ny][p.used] = p.HP - L[nx][ny]; que.push(node{nx,ny,tbl[nx][ny][p.used],p.used}); } } } } cout << "NO" << endl; return 0; }