結果
問題 |
No.1638 Robot Maze
|
ユーザー |
|
提出日時 | 2021-08-07 03:22:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,111 bytes |
コンパイル時間 | 1,755 ms |
コンパイル使用メモリ | 126,824 KB |
最終ジャッジ日時 | 2025-01-23 16:34:14 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 WA * 11 TLE * 2 MLE * 1 |
ソースコード
// #define _GLIBCXX_DEBUG #include <algorithm> #include <cmath> #include <complex> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using ld = long double; using P = pair<int, int>; // #include <atcoder> // using namespace atcoder; // using mint = modint1000000007; // #include <boost/multiprecision/cpp_dec_float.hpp> // #include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; // using Bint = mp::cpp_int; // using Bdouble = mp::number<mp::cpp_dec_float<32>>; const ll MAX = 1e18; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int h, w; cin >> h >> w; vector v(h + 2, vector<char>(w + 2, '#')); ll u, d, r, l, k, p; cin >> u >> d >> r >> l >> k >> p; int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; for (int i = 1; i < h + 1; i++) { for (int j = 1; j < w + 1; j++) { cin >> v[i][j]; } } deque<vector<int>> dq; v[xt][yt] = 'g'; dq.push_back({xs, ys, 0}); vector<int> D[4] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; bool fg = 0; vector cnt(h + 2, vector<vector<ll>>(w + 2, {MAX, MAX, MAX, MAX, MAX})); cnt[xs][ys] = {0, 0, 0, 0, 0}; while (!dq.empty()) { auto fr = dq.front(); dq.pop_front(); v[fr[0]][fr[1]] = '*'; for (int i = 0; i < 4; i++) { int a = fr[0] + D[i][0]; int b = fr[1] + D[i][1]; if (v[a][b] == 'g') { fg = 1; cnt[a][b] = cnt[fr[0]][fr[1]]; if (i == 0) { cnt[a][b][0]++; } else if (i == 1) { cnt[a][b][1]++; } else if (i == 2) { cnt[a][b][2]++; } else { cnt[a][b][3]++; } break; } else if (v[a][b] == '.') { dq.push_front({a, b, 0}); cnt[a][b] = cnt[fr[0]][fr[1]]; if (i == 0) { cnt[a][b][0]++; } else if (i == 1) { cnt[a][b][1]++; } else if (i == 2) { cnt[a][b][2]++; } else { cnt[a][b][3]++; } } else if (v[a][b] == '@') { dq.push_back({a, b, 1}); cnt[a][b] = cnt[fr[0]][fr[1]]; cnt[a][b][4]++; if (i == 0) { cnt[a][b][0]++; } else if (i == 1) { cnt[a][b][1]++; } else if (i == 2) { cnt[a][b][2]++; } else { cnt[a][b][3]++; } } } } if (cnt[xt][yt][0] * u + cnt[xt][yt][1] * d + cnt[xt][yt][2] * r + cnt[xt][yt][3] * l + cnt[xt][yt][4] * p <= k) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }