結果

問題 No.323 yuki国
ユーザー kurenaifkurenaif
提出日時 2016-04-19 19:40:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 2,277 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 92,032 KB
実行使用メモリ 7,608 KB
最終ジャッジ日時 2023-09-10 21:26:54
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,388 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 38 ms
6,228 KB
testcase_09 AC 37 ms
6,140 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 5 ms
5,976 KB
testcase_12 AC 5 ms
7,472 KB
testcase_13 AC 36 ms
6,180 KB
testcase_14 AC 39 ms
6,316 KB
testcase_15 AC 32 ms
7,144 KB
testcase_16 AC 38 ms
7,596 KB
testcase_17 AC 41 ms
5,976 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 29 ms
7,460 KB
testcase_20 AC 3 ms
4,384 KB
testcase_21 AC 55 ms
7,608 KB
testcase_22 AC 17 ms
4,380 KB
testcase_23 AC 54 ms
5,880 KB
testcase_24 AC 6 ms
5,404 KB
testcase_25 AC 44 ms
7,508 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 7 ms
4,380 KB
testcase_28 AC 45 ms
6,228 KB
testcase_29 AC 44 ms
6,192 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define pii pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define pi 2*acos(0.0)
#define INFILE() freopen("in.txt","r",stdin)
#define OUTFILE() freopen("out.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14

// l = list(map(int, input().split()))
// l = ts = [input() for i in range(n)]

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };

struct point {
	int x, y;
	point(int x_, int y_):x(x_), y(y_){}
	point(){}
};

bool operator < (const point& left, const point& right) {
	return left.y < right.y;
}

bool used[2000][51][51] = {};

int main(void) {
	int H, W; cin >> H >> W;
	int A; cin >> A;
	point S; cin >> S.y >> S.x;
	int B; cin >> B;
	point G; cin >> G.y >> G.x;
	vector<string> M(H);
	for (auto &a : M) cin >> a;

	int cut = max(A, B) + H + W;//これ以上行くパターンはウロウロしてるのでいらない

	queue<pair<int, point>> que;
	que.push(mp(A, point(S)));
	used[A][S.y][S.x] = true;

	while (not que.empty()) {
		auto t = que.front(); que.pop();
		int x = t.second.x;
		int y = t.second.y;
		if (used[B][G.y][G.x]) break;
		REP(i, 4) {
			if (0 <= x + dx[i] and x + dx[i] < W and 0 <= y + dy[i] and y + dy[i] < H) {
				int score = t.first + (M[y + dy[i]][x + dx[i]] == '.' ? -1 : 1);
				if (not used[score][y + dy[i]][x + dx[i]]) {
					used[score][y + dy[i]][x + dx[i]] = true;
					if (score <= 0 or score > cut) continue;
					que.push(mp(score, point(x + dx[i], y + dy[i])));
				}
			}
		}
	}

	cout << (used[B][G.y][G.x] ? "Yes" : "No") << endl;;
	return 0;
}
0