結果

問題 No.323 yuki国
ユーザー motimoti
提出日時 2015-12-16 01:07:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,722 bytes
コンパイル時間 1,035 ms
コンパイル使用メモリ 113,848 KB
実行使用メモリ 103,536 KB
最終ジャッジ日時 2023-10-14 10:32:27
合計ジャッジ時間 14,221 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 AC 5 ms
4,352 KB
testcase_03 AC 1 ms
4,356 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 6 ms
4,452 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1,127 ms
101,504 KB
testcase_09 AC 612 ms
64,040 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 520 ms
55,420 KB
testcase_14 AC 1,090 ms
103,536 KB
testcase_15 AC 441 ms
48,672 KB
testcase_16 AC 1,131 ms
101,544 KB
testcase_17 AC 540 ms
53,368 KB
testcase_18 AC 4 ms
4,352 KB
testcase_19 AC 667 ms
64,324 KB
testcase_20 AC 9 ms
4,796 KB
testcase_21 AC 1,314 ms
103,432 KB
testcase_22 AC 137 ms
19,544 KB
testcase_23 AC 1,220 ms
103,360 KB
testcase_24 AC 31 ms
8,280 KB
testcase_25 AC 490 ms
52,816 KB
testcase_26 AC 30 ms
8,068 KB
testcase_27 AC 1,230 ms
102,592 KB
testcase_28 AC 552 ms
56,908 KB
testcase_29 AC 583 ms
57,368 KB
testcase_30 AC 1 ms
4,368 KB
testcase_31 AC 2 ms
4,352 KB
testcase_32 AC 3 ms
4,348 KB
testcase_33 AC 2 ms
4,368 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 3 ms
4,352 KB
testcase_37 AC 2 ms
4,348 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