結果

問題 No.323 yuki国
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-08-09 11:48:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 145 ms / 5,000 ms
コード長 1,307 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 67,784 KB
実行使用メモリ 8,716 KB
最終ジャッジ日時 2023-09-10 21:34:53
合計ジャッジ時間 3,720 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 8 ms
8,420 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 9 ms
8,428 KB
testcase_04 AC 8 ms
8,432 KB
testcase_05 AC 9 ms
8,416 KB
testcase_06 AC 8 ms
8,544 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 60 ms
8,512 KB
testcase_09 AC 59 ms
8,448 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 7 ms
8,716 KB
testcase_12 AC 5 ms
7,432 KB
testcase_13 AC 61 ms
8,432 KB
testcase_14 AC 61 ms
8,460 KB
testcase_15 AC 32 ms
7,520 KB
testcase_16 AC 60 ms
8,516 KB
testcase_17 AC 71 ms
8,448 KB
testcase_18 AC 27 ms
8,432 KB
testcase_19 AC 52 ms
8,516 KB
testcase_20 AC 141 ms
8,604 KB
testcase_21 AC 142 ms
8,544 KB
testcase_22 AC 145 ms
8,536 KB
testcase_23 AC 137 ms
8,456 KB
testcase_24 AC 45 ms
7,516 KB
testcase_25 AC 43 ms
7,512 KB
testcase_26 AC 88 ms
8,452 KB
testcase_27 AC 95 ms
8,716 KB
testcase_28 AC 81 ms
8,516 KB
testcase_29 AC 80 ms
8,472 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 8 ms
8,484 KB
testcase_32 AC 8 ms
8,484 KB
testcase_33 AC 8 ms
8,428 KB
testcase_34 AC 8 ms
8,424 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 8 ms
8,420 KB
testcase_37 AC 8 ms
8,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
int h, w;
int a, si, sj;
int b, gi, gj;
string s[51];
bool board[2010][51][51];
struct t{
	int size, y, x;
	t(int size, int y, int x) : size(size), y(y), x(x) {}
};

int main(void){
	cin >> h >> w;
	cin >> a >> si >> sj;
	cin >> b >> gi >> gj;
	rep(i, h) cin >> s[i];
	queue<t> q;
	q.push(t(a, si, sj));
	board[a][si][sj] = true;
	while(!q.empty()){
		t now = q.front(); q.pop();
		for (int i = 0; i < 4; ++i){
			if(0 <= now.y + dy[i] && now.y + dy[i] < h &&
			   0 <= now.x + dx[i] && now.x + dx[i] < w){
				if(s[now.y + dy[i]][now.x + dx[i]] == '*'){
					if(now.size <= 2000 && board[now.size + 1][now.y + dy[i]][now.x + dx[i]] == false){
						board[now.size + 1][now.y + dy[i]][now.x + dx[i]] = true;
						q.push(t(now.size + 1, now.y + dy[i], now.x + dx[i]));
					}
				}else{
					if(2 <= now.size && board[now.size - 1][now.y + dy[i]][now.x + dx[i]] == false){
						board[now.size - 1][now.y + dy[i]][now.x + dx[i]] = true;
						q.push(t(now.size - 1, now.y + dy[i], now.x + dx[i]));
					}
				}
			}
		}
	}

	if(board[b][gi][gj]) printf("Yes\n");
	else printf("No\n");
	return 0;
}
0