結果

問題 No.323 yuki国
ユーザー simansiman
提出日時 2016-03-28 00:16:37
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,571 bytes
コンパイル時間 892 ms
コンパイル使用メモリ 79,516 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-04-10 04:10:48
合計ジャッジ時間 6,352 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 346 ms
9,600 KB
testcase_09 AC 80 ms
9,600 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 76 ms
9,600 KB
testcase_14 AC 170 ms
9,600 KB
testcase_15 AC 71 ms
9,728 KB
testcase_16 AC 158 ms
9,728 KB
testcase_17 AC 87 ms
9,728 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 RE -
testcase_20 AC 9 ms
9,728 KB
testcase_21 AC 573 ms
9,600 KB
testcase_22 AC 39 ms
9,728 KB
testcase_23 AC 566 ms
9,728 KB
testcase_24 AC 14 ms
9,472 KB
testcase_25 AC 97 ms
9,600 KB
testcase_26 AC 13 ms
9,600 KB
testcase_27 AC 444 ms
9,728 KB
testcase_28 AC 100 ms
9,600 KB
testcase_29 AC 101 ms
9,600 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 1 ms
6,944 KB
testcase_36 RE -
testcase_37 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <time.h>
#include <string>
#include <string.h>
#include <sstream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;
const int DY[4] = {-1, 0, 0, 1};
const int DX[4] = { 0,-1, 1, 0};

struct Node {
  int y;
  int x;
  int val;

  Node(int y, int x, int val){
    this->y = y;
    this->x = x;
    this->val = val;
  }
};

int main(){
  int h, w;
  cin >> h >> w;
  int a, sy, sx;
  cin >> a >> sy >> sx;
  int b, gy, gx;
  cin >> b >> gy >> gx;
  char field[h][w];

  string line;
  for(int y = 0; y < h; y++){
    cin >> line;
    for(int x = 0; x < w; x++){
      field[y][x] = line[x];
    }
  }

  queue<Node> que;
  que.push(Node(sy, sx, a));
  bool checkList[h][w][2500];
  memset(checkList, false, sizeof(checkList));

  while(!que.empty()){
    Node node = que.front(); que.pop();
    int y = node.y;
    int x = node.x;
    int val = node.val;

    if(val == 0) continue;
    if(checkList[y][x][val]) continue;
    checkList[y][x][val] = true;

    if(val == b && y == gy && x == gx){
      cout << "Yes" << endl;
      return 0;
    }

    for(int i = 0; i < 4; i++){
      int ny = y + DY[i];
      int nx = x + DX[i];

      if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;

      if(field[ny][nx] == '*'){
        que.push(Node(ny, nx, val+1));
      }else{
        que.push(Node(ny, nx, val-1));
      }
    }
  }

  cout << "No" << endl;
  return 0;
}
0