結果

問題 No.2646 Cycle Maze
ユーザー tnakao0123tnakao0123
提出日時 2024-04-25 10:26:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,293 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 59,008 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 10:26:27
合計ジャッジ時間 4,054 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 10 ms
5,376 KB
testcase_27 AC 29 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 7 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 6 ms
5,376 KB
testcase_34 AC 19 ms
5,376 KB
testcase_35 AC 16 ms
5,376 KB
testcase_36 AC 10 ms
5,376 KB
testcase_37 AC 5 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 8 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 10 ms
5,376 KB
testcase_42 AC 6 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 7 ms
5,376 KB
testcase_45 AC 71 ms
5,376 KB
testcase_46 AC 66 ms
5,376 KB
testcase_47 AC 3 ms
5,376 KB
testcase_48 AC 42 ms
5,376 KB
testcase_49 AC 59 ms
5,376 KB
testcase_50 AC 153 ms
5,376 KB
testcase_51 AC 316 ms
5,376 KB
testcase_52 AC 344 ms
5,376 KB
testcase_53 AC 322 ms
5,376 KB
testcase_54 AC 323 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2646.cc:  No.2646 Cycle Maze - yukicoder
 */

#include<cstdio>
#include<queue>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_H = 200;
const int MAX_W = 200;
const int MAX_HW = MAX_H * MAX_W;
const int dxs[] = { 1, 0, -1, 0, 0 }, dys[] = { 0, -1, 0, 1, 0 };

/* typedef */

typedef queue<int> qi;

/* global variables */

char s[MAX_HW + 4];
bool ds[MAX_HW];

/* subroutines */

/* main */

int main() {
  int h, w, t, sy, sx, gy, gx;
  scanf("%d%d%d%d%d%d%d", &h, &w, &t, &sy, &sx, &gy, &gx);
  sy--, sx--, gy--, gx--;
  int hw = h * w, st = sy * w + sx, gl = gy * w + gx;

  for (int i = 0; i < h; i++) scanf("%s", s + i * w);

  qi uq;
  uq.push(st);
  int d = 0;

  while (d < t) {
    d++;
    fill(ds, ds + hw, false);
    qi vq;

    while (! uq.empty()) {
      int u = uq.front(); uq.pop();
      int uy = u / w, ux = u % w;

      for (int di = 0; di < 5; di++) {
	int vy = uy + dys[di], vx = ux + dxs[di], v = vy * w + vx;
	if (vy >= 0 && vy < h && vx >= 0 && vx < w && ! ds[v]) {
	  int av = (s[v] - '0');
	  int bv = (av - d) % (av + 1);
	  if (bv != 0) {
	    ds[v] = true;
	    vq.push(v);
	  }
	}
      }
    }

    if (ds[gl]) break;
    swap(uq, vq);
  }

  if (ds[gl]) puts("Yes");
  else puts("No");

  return 0;
}
0