結果

問題 No.323 yuki国
ユーザー motimoti
提出日時 2015-12-16 00:50:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,039 bytes
コンパイル時間 2,951 ms
コンパイル使用メモリ 107,168 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2023-10-14 10:31:34
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,368 KB
testcase_08 WA -
testcase_09 AC 48 ms
9,588 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 23 ms
6,896 KB
testcase_14 WA -
testcase_15 AC 12 ms
5,304 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 23 ms
6,928 KB
testcase_18 AC 6 ms
4,488 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,368 KB
testcase_21 WA -
testcase_22 AC 30 ms
7,888 KB
testcase_23 WA -
testcase_24 AC 44 ms
9,036 KB
testcase_25 WA -
testcase_26 AC 40 ms
8,892 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,368 KB
testcase_29 AC 2 ms
4,368 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 1 ms
4,368 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> G[2][50][50];
unordered_set<int> vis[50][50];
//set<int> G[2002][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];
  }

  G[0][si][sj].insert(A);
  vis[si][sj].insert(A);
  rep(k, 2001) {
    rep(i, H) rep(j, W) G[(k+1)&1][i][j].clear();
    rep(i, H) rep(j, W) {
      for(auto const& e: G[k&1][i][j]) {
        if(e - 1 < 0) { continue; }
        rep(d, 4) {
          auto const ni = i + dy[d], nj = j + dx[d];
          if(!in_range(ni, nj, H, W)) { continue; }
          if(ni == gi && nj == gj) {
            cout << "Yes" << endl;
            exit(0);
          }
          int const nc = e + (yuki[ni][nj] == '*' ? 1 : -1);
          if(vis[ni][nj].count(nc)) { continue; }
          vis[ni][nj].insert(nc);
          G[(k+1)&1][ni][nj].insert(nc);
        }
      }
    }
    /*
    rep(i, H) {
      rep(j, W) {
        cout << (G[k][i][j].empty() ? 0 : *G[k][i][j].begin()) << " ";
      }
      cout << endl;
    }
    cout << "\n-------------------\n";
    */
  }

  cout << "No" << endl;

  return 0;
}
0