結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2021-08-06 22:50:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,241 bytes |
| コンパイル時間 | 831 ms |
| コンパイル使用メモリ | 85,952 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-17 03:03:05 |
| 合計ジャッジ時間 | 2,376 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
int INF = 1e+18;
int h, w;
int cst[4];
int dy[4] = {-1, 1, 0, 0}; //U, D, R, L
int dx[4] = {0, 0, 1, -1};
int K, p;
int sy, sx, gy, gx;
string s[100];
int dp[100][100];
signed main() {
int i, j;
cin >> h >> w;
cin >> cst[0] >> cst[1] >> cst[2] >> cst[3] >> K >> p;
cin >> sy >> sx >> gy >> gx;
sy--; sx--; gy--; gx--;
rep(i, h) cin >> s[i];
rep(i, h) rep(j, w) dp[i][j] = INF;
typedef tuple<int, int, int> T;
priority_queue<T, vector<T>, greater<T>> que;
que.push(T(0, sy, sx));
while (!que.empty()) {
T now = que.top(); que.pop();
int dist = get<0>(now);
int y = get<1>(now);
int x = get<2>(now);
if (dp[y][x] <= dist) continue;
dp[y][x] = dist;
rep(i, 4) {
int ny = y + dy[i];
int nx = x + dx[i];
int ndist = dist + cst[i];
if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
if (s[ny][nx] == '#') continue;
if (s[ny][nx] == '@') ndist += p;
que.push(T(ndist, ny, nx));
}
}
if (dp[gy][gx] > K) cout << "No" << endl;
else cout << "Yes" << endl;
return 0;
}
startcpp