結果

問題 No.323 yuki国
ユーザー latte0119latte0119
提出日時 2016-05-24 18:45:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 1,488 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 80,212 KB
実行使用メモリ 8,552 KB
最終ジャッジ日時 2023-09-10 21:29:16
合計ジャッジ時間 3,989 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 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,376 KB
testcase_08 AC 66 ms
8,300 KB
testcase_09 AC 66 ms
8,396 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 69 ms
8,232 KB
testcase_14 AC 67 ms
8,248 KB
testcase_15 AC 40 ms
8,552 KB
testcase_16 AC 67 ms
8,256 KB
testcase_17 AC 85 ms
8,244 KB
testcase_18 AC 25 ms
4,924 KB
testcase_19 AC 50 ms
6,712 KB
testcase_20 AC 104 ms
8,488 KB
testcase_21 AC 111 ms
8,260 KB
testcase_22 AC 109 ms
8,324 KB
testcase_23 AC 108 ms
8,300 KB
testcase_24 AC 47 ms
8,252 KB
testcase_25 AC 49 ms
8,244 KB
testcase_26 AC 92 ms
8,256 KB
testcase_27 AC 86 ms
8,244 KB
testcase_28 AC 92 ms
8,360 KB
testcase_29 AC 89 ms
8,460 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<sstream>
#include<bitset>
#include<numeric>
#include<climits>
using namespace std;

typedef long long ll;

template<typename A,typename B>inline void chmin(A &a, B b) { if (a > b)a = b; }
template<typename A,typename B>inline void chmax(A &a, B b) { if (a < b)a = b; }


int H, W;
int A, sy, sx;
int B, gy, gx;
int fld[50][50];
const int dx[] = { -1,0,1,0 };
const int dy[] = { 0,-1,0,1 };
const int lim = 2000;

bool vis[50][50][lim];

int main() {
	cin >> H >> W;
	cin >> A >> sy >> sx;
	cin >> B >> gy >> gx;
	A--; B--;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c;
			cin >> c;
			fld[i][j] = c == '*' ? 1 : -1;
		}
	}
	queue<tuple<int, int, int>>que;
	que.push(make_tuple(sy, sx, A));
	vis[sy][sx][A] = true;

	while (que.size()) {
		int y, x, s;
		tie(y, x, s) = que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			int ny = y + dy[i], nx = x + dx[i];
			if (ny < 0 || ny >= H)continue;
			if(nx < 0 || nx >= W)continue;
			if (s + fld[ny][nx] < 0 || s + fld[ny][nx] >= lim)continue;
			if (vis[ny][nx][s + fld[ny][nx]])continue;
			vis[ny][nx][s + fld[ny][nx]] = true;
			que.push(make_tuple(ny, nx, s + fld[ny][nx]));
		}
	}

	if (vis[gy][gx][B])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
0