結果
| 問題 |
No.20 砂漠のオアシス
|
| コンテスト | |
| ユーザー |
ゆぽ
|
| 提出日時 | 2016-05-13 23:52:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,933 bytes |
| コンパイル時間 | 797 ms |
| コンパイル使用メモリ | 94,720 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-10-13 05:37:03 |
| 合計ジャッジ時間 | 1,782 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 RE * 1 |
ソースコード
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(),(c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define ABS(a) ((a)>0?(a):-(a))
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define INF (1000000)
int N, V, Ox, Oy;
int L[202][202];
int c[202][202], d[202][202];
typedef pair<int, pair<int, int>> P;
int ar[4][2] = { { 1, 0 }, { 0, -1 }, { -1, 0 }, { 0, 1 } };
void wf(int a[202][202], int sx, int sy) {
priority_queue<P, vector<P>, greater<P>> q;
q.push(MP(0, MP(sx, sy)));
while (!q.empty()) {
P t = q.top(); q.pop();
int v = t.first, x = t.second.first, y = t.second.second;
REP(i, 4) {
int ax = x + ar[i][0], ay = y + ar[i][1];
if (a[ax][ay] > v + L[ax][ay]) {
a[ax][ay] = v + L[ax][ay];
q.push(MP(a[ax][ay], MP(ax, ay)));
}
}
}
}
int main(int argc, char **argv) {
cin >> N >> V >> Ox >> Oy;
FOR(y, 1, N + 1) FOR(x, 1, N + 1) {
cin >> L[x][y];
c[x][y] = d[x][y] = INF;
}
REP(i, N + 2) {
L[i][0] = L[i][N + 1] = L[0][i] = L[N + 1][i] = INF;
c[i][0] = c[i][N + 1] = c[0][i] = c[N + 1][i] = -1;
d[i][0] = d[i][N + 1] = d[0][i] = d[N + 1][i] = -1;
}
wf(c, 1, 1);
bool res = c[N][N] < V;
if (!res && c[Ox][Oy] < V) {
wf(d, Ox, Oy);
res = d[N][N] < (V - c[Ox][Oy]) * 2;
}
cout << (res ? "YES" : "NO") << endl;
return 0;
}
ゆぽ