結果
| 問題 | 
                            No.1638 Robot Maze
                             | 
                    
| コンテスト | |
| ユーザー | 
                             siman
                         | 
                    
| 提出日時 | 2021-08-08 18:19:01 | 
| 言語 | C++17(clang)  (17.0.6 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,781 bytes | 
| コンパイル時間 | 5,456 ms | 
| コンパイル使用メモリ | 143,344 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-19 14:59:10 | 
| 合計ジャッジ時間 | 3,447 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 WA * 12 | 
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
const int DY[4] = {-1, 0, 1, 0};
const int DX[4] = {0, 1, 0, -1};
struct Node {
  int y;
  int x;
  ll cost;
  Node(int y = -1, int x = -1, ll cost = -1) {
    this->y = y;
    this->x = x;
    this->cost = cost;
  }
  bool operator>(const Node &n) const {
    return cost > n.cost;
  }
};
int main() {
  int H, W;
  cin >> H >> W;
  ll U, D, R, L, K, P;
  cin >> U >> D >> R >> L >> K >> P;
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  char C[H + 1][W + 1];
  for (int y = 1; y <= H; ++y) {
    for (int x = 1; x <= W; ++x) {
      cin >> C[y][x];
    }
  }
  priority_queue <Node, vector<Node>, greater<Node>> pque;
  pque.push(Node(sy, sx, 0));
  bool visited[H + 1][W + 1];
  memset(visited, false, sizeof(visited));
  while (not pque.empty()) {
    Node node = pque.top();
    pque.pop();
    if (node.cost > K) continue;
    if (visited[node.y][node.x]) continue;
    visited[node.y][node.x] = true;
    if (node.y == ty && node.x == tx) {
      cout << "Yes" << endl;
      return 0;
    }
    for (int direct = 0; direct < 4; ++direct) {
      int ny = node.y + DY[direct];
      int nx = node.x + DX[direct];
      if (ny <= 0 || nx <= 0 || H < ny || W < nx) continue;
      if (C[ny][nx] == '#') continue;
      ll ncost = node.cost;
      if (C[ny][nx] == '@') ncost += P;
      if (direct == 0) ncost += U;
      if (direct == 1) ncost += R;
      if (direct == 2) ncost += D;
      if (direct == 3) ncost += L;
      pque.push(Node(ny, nx, ncost));
    }
  }
  cout << "No" << endl;
  return 0;
}
            
            
            
        
            
siman