結果
問題 | No.1638 Robot Maze |
ユーザー |
|
提出日時 | 2021-08-06 21:35:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,999 bytes |
コンパイル時間 | 2,242 ms |
コンパイル使用メモリ | 207,592 KB |
最終ジャッジ日時 | 2025-01-23 14:46:31 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 WA * 13 |
ソースコード
#include <bits/stdc++.h>#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))#define ALL(x) ::std::begin(x), ::std::end(x)using namespace std;template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;// generated by oj-template v4.8.0 (https://github.com/online-judge-tools/template-generator)const std::string YES = "Yes";const std::string NO = "No";int main() {// inputint h, w, up, down, left, right;int64_t k, p;cin >> h >> w >> up >> down >> left >> right >> k >> p;int sx, sy, tx, ty;cin >> sx >> sy >> tx >> ty;-- sx;-- sy;-- tx;-- ty;vector<string> c(h);REP (y, h) { cin >> c[y]; }// solvevector<vector<int64_t>> dist(h, vector<int64_t>(w, INT64_MAX));reversed_priority_queue<tuple<int64_t, int, int>> que;dist[sy][sx] = 0;que.emplace(0, sy, sx);while (not que.empty()) {auto [dist_y_x, y, x] = que.top();que.pop();if (dist_y_x > dist[y][x]) {continue;}REP (i, 4) {const int dy[4] = {-1, 1, 0, 0};const int dx[4] = {0, 0, 1, -1};int ny = y + dy[i];int nx = x + dx[i];if (0 <= ny and ny < h and 0 <= nx and nx < w) {if (c[ny][nx] == '#') {continue;}const int cost[4] = {up, down, right, left};int64_t ndist = dist[y][x] + cost[i] + (c[ny][nx] == '@' ? p : 0);if (ndist < dist[ny][nx]) {dist[ny][nx] = ndist;que.emplace(ndist, ny, nx);}}}}bool ans = dist[ty][tx] <= k;// outputcout << (ans ? YES : NO) << '\n';return 0;}