結果

問題 No.323 yuki国
ユーザー motimoti
提出日時 2015-12-16 01:11:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,318 ms / 5,000 ms
コード長 1,723 bytes
コンパイル時間 972 ms
コンパイル使用メモリ 113,900 KB
実行使用メモリ 103,416 KB
最終ジャッジ日時 2023-09-10 21:17:39
合計ジャッジ時間 14,100 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1,083 ms
101,792 KB
testcase_09 AC 595 ms
64,148 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 516 ms
55,372 KB
testcase_14 AC 1,208 ms
103,388 KB
testcase_15 AC 427 ms
48,652 KB
testcase_16 AC 1,117 ms
101,584 KB
testcase_17 AC 524 ms
53,184 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 675 ms
64,248 KB
testcase_20 AC 9 ms
4,888 KB
testcase_21 AC 1,318 ms
103,332 KB
testcase_22 AC 145 ms
19,448 KB
testcase_23 AC 1,224 ms
103,416 KB
testcase_24 AC 32 ms
8,288 KB
testcase_25 AC 488 ms
52,764 KB
testcase_26 AC 30 ms
8,184 KB
testcase_27 AC 1,216 ms
102,868 KB
testcase_28 AC 557 ms
56,940 KB
testcase_29 AC 549 ms
57,368 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 4 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 3 ms
4,376 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; }

unordered_set<int> vis[50][50];

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].insert(A);
  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].count(nc)) { continue; }
      if(ni == gi && nj == gj && nc == B) {
        cout << "Yes" << endl;
        exit(0);
      }
      vis[ni][nj].insert(nc);
      q.emplace(ni, nj, nc);
    }
  }

  cout << "No" << endl;

  return 0;
}
0