結果

問題 No.323 yuki国
ユーザー motimoti
提出日時 2015-12-16 01:39:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 1,697 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 109,000 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2023-09-10 21:17:48
合計ジャッジ時間 2,815 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 40 ms
6,120 KB
testcase_09 AC 39 ms
6,400 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 40 ms
6,112 KB
testcase_14 AC 41 ms
6,108 KB
testcase_15 AC 38 ms
6,132 KB
testcase_16 AC 39 ms
6,236 KB
testcase_17 AC 48 ms
6,132 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 30 ms
5,148 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 63 ms
6,028 KB
testcase_22 AC 20 ms
5,780 KB
testcase_23 AC 56 ms
5,920 KB
testcase_24 AC 7 ms
6,132 KB
testcase_25 AC 51 ms
6,184 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 6 ms
4,376 KB
testcase_28 AC 54 ms
6,116 KB
testcase_29 AC 53 ms
6,148 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,376 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; }

int main() {

  int H, W, A, si, sj, B, gi, gj; scanf("%d%d%d%d%d%d%d%d", &H,&W,&A,&si,&sj,&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);
  bool vis[H][W][max(A,B)+H+W-1]; zero(vis);
  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) {
        puts("Yes");
        exit(0);
      }
      vis[ni][nj][nc] = 1;
      q.emplace(ni, nj, nc);
    }
  }

  puts("No");

  return 0;
}
0