結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 66 ms
8,288 KB
testcase_09 AC 40 ms
8,248 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 40 ms
8,380 KB
testcase_14 AC 67 ms
8,284 KB
testcase_15 AC 36 ms
8,300 KB
testcase_16 AC 65 ms
8,268 KB
testcase_17 AC 47 ms
8,256 KB
testcase_18 AC 4 ms
4,724 KB
testcase_19 AC 50 ms
6,532 KB
testcase_20 AC 5 ms
5,920 KB
testcase_21 AC 111 ms
8,312 KB
testcase_22 AC 20 ms
8,272 KB
testcase_23 AC 104 ms
8,312 KB
testcase_24 AC 11 ms
8,300 KB
testcase_25 AC 48 ms
8,528 KB
testcase_26 AC 11 ms
8,268 KB
testcase_27 AC 86 ms
8,252 KB
testcase_28 AC 51 ms
8,260 KB
testcase_29 AC 50 ms
8,344 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,376 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 > 2000) { 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