結果
| 問題 |
No.20 砂漠のオアシス
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2015-05-07 11:35:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,305 bytes |
| コンパイル時間 | 691 ms |
| コンパイル使用メモリ | 75,744 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 05:10:58 |
| 合計ジャッジ時間 | 1,867 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 6 |
ソースコード
/*
* 020.cpp
*
* Created on: 2015/05/07
* Author: 祐也
*/
#include<iostream>
#include<queue>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int> PI;
typedef pair<int,PI> V;
const int d[5]={0,1,0,-1,0};
int cost[201][201];
int dijkstra(PI s,PI t,int n){
int dist[202][202];
for(int i=1;i<=n;i++)for(int j=0;j<=n;j++)dist[i][j]=-1;
for(int i=0;i<=n+1;i++)dist[0][i]=dist[i][0]=dist[n+1][i]=dist[i][n+1]=0;
priority_queue<V,vector<V>,greater<V> > que;
que.push(make_pair(0,s));
while(que.empty()==false){
PI v=que.top().second;
int di=que.top().first;
que.pop();
if(dist[v.first][v.second]>=0)continue;
dist[v.first][v.second]=di;
for(int i=0;i<4;i++){
PI p=v;
p.first+=d[i];
p.second+=d[i+1];
if(dist[p.first][p.second]>=0)continue;
que.push(make_pair(di+cost[p.first][p.second],p));
}
}
return dist[t.first][t.second];
}
int main(){
int N;
int V;
PI O;
cin>>N>>V>>O.first>>O.second;
for(int i=1;i<=N;i++)
for(int j=1;j<=N;j++)
cin>>cost[i][j];
auto st=make_pair(1,1);
auto ed=make_pair(N,N);
if(dijkstra(st,ed,N)<V){
cout<<"YES"<<endl;
}
else {
int U=(V-dijkstra(st,O,N))*2;
if(U>0&&U-dijkstra(O,ed,N)>0)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
btk