結果

問題 No.323 yuki国
ユーザー motimoti
提出日時 2015-12-16 01:23:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 60 ms / 5,000 ms
コード長 1,720 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 107,548 KB
実行使用メモリ 8,540 KB
最終ジャッジ日時 2023-09-10 21:17:23
合計ジャッジ時間 3,030 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 41 ms
8,264 KB
testcase_09 AC 42 ms
8,308 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 42 ms
8,300 KB
testcase_14 AC 43 ms
8,220 KB
testcase_15 AC 37 ms
8,300 KB
testcase_16 AC 42 ms
8,416 KB
testcase_17 AC 49 ms
8,264 KB
testcase_18 AC 3 ms
4,688 KB
testcase_19 AC 29 ms
6,468 KB
testcase_20 AC 6 ms
5,932 KB
testcase_21 AC 60 ms
8,312 KB
testcase_22 AC 21 ms
8,380 KB
testcase_23 AC 56 ms
8,244 KB
testcase_24 AC 11 ms
8,540 KB
testcase_25 AC 51 ms
8,276 KB
testcase_26 AC 11 ms
8,424 KB
testcase_27 AC 12 ms
8,224 KB
testcase_28 AC 54 ms
8,352 KB
testcase_29 AC 52 ms
8,304 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define minimize(a, x) a = std::min(a, x)
#define maximize(a, x) a = std::max(a, x)

typedef long long ll;
int const inf = 1<<29;

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

bool vis[50][50][2001];

int main() {

  int H, W; cin >> H >> W;
  int A, si, sj; cin >> A >> si >> sj;
  int B, gi, gj; cin >> B >> gi >> gj;

  char yuki[H][W+1];
  rep(i, H) {
    cin >> yuki[i];
  }

  queue<tuple<int, int, int>> q;
  q.emplace(si, sj, A);
  vis[si][sj][A] = 1;
  while(!q.empty()) {
    auto p = q.front(); q.pop();
    int i, j, c; tie(i, j, c) = p;
    rep(d, 4) {
      auto const ni = i + dy[d], nj = j + dx[d];
      if(!in_range(ni, nj, H, W)) { continue; }
      int const nc = c + (yuki[ni][nj] == '*' ? 1 : -1);
      if(nc <= 0 || nc > max(A, B) + H + W - 2) { continue; }
      if(vis[ni][nj][nc]) { continue; }
      if(ni == gi && nj == gj && nc == B) {
        cout << "Yes" << endl;
        exit(0);
      }
      vis[ni][nj][nc] = 1;
      q.emplace(ni, nj, nc);
    }
  }

  cout << "No" << endl;

  return 0;
}
0