結果

問題 No.2646 Cycle Maze
ユーザー matcharate12matcharate12
提出日時 2024-02-14 13:30:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,422 ms / 2,500 ms
コード長 1,638 bytes
コンパイル時間 1,724 ms
コンパイル使用メモリ 180,328 KB
実行使用メモリ 102,528 KB
最終ジャッジ日時 2024-02-25 17:31:02
合計ジャッジ時間 14,462 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 422 ms
28,928 KB
testcase_26 AC 275 ms
21,376 KB
testcase_27 AC 274 ms
26,112 KB
testcase_28 AC 54 ms
7,296 KB
testcase_29 AC 454 ms
31,104 KB
testcase_30 AC 296 ms
21,888 KB
testcase_31 AC 182 ms
18,432 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 14 ms
8,192 KB
testcase_34 AC 41 ms
12,928 KB
testcase_35 AC 226 ms
19,456 KB
testcase_36 AC 19 ms
7,808 KB
testcase_37 AC 63 ms
16,256 KB
testcase_38 AC 50 ms
6,676 KB
testcase_39 AC 280 ms
21,376 KB
testcase_40 AC 136 ms
12,800 KB
testcase_41 AC 229 ms
18,816 KB
testcase_42 AC 26 ms
6,676 KB
testcase_43 AC 26 ms
6,676 KB
testcase_44 AC 100 ms
11,008 KB
testcase_45 AC 295 ms
35,840 KB
testcase_46 AC 364 ms
46,080 KB
testcase_47 AC 1,422 ms
94,208 KB
testcase_48 AC 276 ms
38,144 KB
testcase_49 AC 1,388 ms
96,384 KB
testcase_50 AC 325 ms
51,456 KB
testcase_51 AC 767 ms
75,008 KB
testcase_52 AC 867 ms
80,128 KB
testcase_53 AC 1,307 ms
102,528 KB
testcase_54 AC 1,304 ms
102,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < n; i++) //[0,n)
#define srep(i,a,b) for(ll i = a; i < b; i++) //[a,b)
//#define all(A) (A).begin(),(A).end()
//#define rall(A) (A).rbegin(),(A).rend()
//#define pmt(A) next_permutation(all(A))
using namespace std;
using ll = long long;
//using ull = unsigned long long;
//using P = pair<ll,ll>;
//using pq = priority_queue<P,vector<P>,greater<P>>;
//ll inf = 1LL<<60;
//int iinf = (int)1e9+1;
//int mod9 = 998244353;
//int mod1 = 1000000007;
//struct Edge { int to; int cost; int from; };
//bool compe(const Edge &e,const Edge &e2){ return e.cost < e2.cost; }
//using Graph = vector<vector<ll>>;
//using SGraph = vector<set<ll>>;
//template <typename T>
//int siz(T& a){return (int)a.size();}
//ll squa(ll a){ return a*a; }
//ll ceil(ll a,ll b){ return (a+b-1)/b; }

int H,W,T;
vector<vector<vector<int>>> seen;
int dx[5] = {0,0,0,-1,1};
int dy[5] = {0,1,-1,0,0};

void dfs(const vector<string> &S,int y,int x,int t){
	if(t > T) return;
	seen[t][y][x] = 1;

	rep(i,5){
		int ny = y+dy[i],nx = x+dx[i];
		if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;

		int c = S[ny][nx]-'0';
		int mod = (-(t+1))%(c+1);
		while(mod < 0) mod += c+1;

		if(mod == 0) continue;
		if(seen[t+1][ny][nx]) continue;

		dfs(S,ny,nx,t+1);
	}
}

int main(void){
	cin >> H >> W >> T;
	int sy,sx,gy,gx; cin >> sy >> sx >> gy >> gx;
	sx--; sy--; gy--; gx--;

	vector<string> S(H);
	rep(i,H) cin >> S[i];

	seen.assign(T+3,vector<vector<int>>(H,vector<int>(W,0)));
	seen[1][sy][sx] = 1;

	dfs(S,sy,sx,1);

	bool ok = 0;
	srep(i,1,T+1+1) ok |= seen[i][gy][gx];
	cout << (ok ? "Yes" : "No") << endl;

}
0