結果

問題 No.323 yuki国
ユーザー kurenaifkurenaif
提出日時 2016-04-19 19:11:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,180 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 102,136 KB
実行使用メモリ 814,004 KB
最終ジャッジ日時 2024-04-15 03:46:28
合計ジャッジ時間 5,614 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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 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;

		used[t.first][t.second.y][t.second.x] = true;
		if (used[B][G.y][G.x]) break;
		if (t.first <= 0 or t.first > cut) continue;
		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]]) que.push(mp(score, point(x + dx[i], y + dy[i])));
			}
		}
	}

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