結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-06 22:19:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,557 bytes |
| コンパイル時間 | 1,021 ms |
| コンパイル使用メモリ | 102,640 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-17 02:23:26 |
| 合計ジャッジ時間 | 2,475 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int b1[4] = { -1,1,0,0 };
int b2[4] = { 0,0,1,-1 };
long long b3[4];
string s[110];
bool bo[110][110] = { false };
int main() {
long long h, w;
cin >> h >> w;
long long u, d, r, l, k, p;
cin >> u >> d >> r >> l >> k >> p;
b3[0] = u, b3[1] = d, b3[2] = r, b3[3] = l;
int sx, sy, gx, gy;
cin >> sx >> sy >> gx >> gy;
sx--, sy--, gx--, gy--;
for (int i = 0; i < h; i++) {
cin >> s[i];
}
priority_queue<tuple<long long, int, int>, vector<tuple<long long, int, int>>, greater<tuple<long long, int, int>>> que;
que.push({ 0,sx,sy });
while (!que.empty()) {
tuple<long long, int, int> t = que.top();
que.pop();
long long z = get<0>(t);
int x = get<1>(t);
int y = get<2>(t);
if (bo[x][y]) {
continue;
}
bo[x][y] = true;
if (x == gx && y == gy) {
if (z <= k) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
return 0;
}
for (int i = 0; i < 4; i++) {
if (x + b1[i] < 0 || x + b1[i] >= h || y + b2[i] < 0 || y + b2[i] >= w)continue;
if (!bo[x + b1[i]][y + b2[i]]) {
if (s[x + b1[i]][y + b2[i]] == '.') {
que.push({ z + b3[i],x + b1[i],y + b2[i] });
}
if (s[x + b1[i]][y + b2[i]] == '@') {
que.push({ z + b3[i] + p,x + b1[i],y + b2[i] });
}
}
}
}
cout << "No" << endl;
}