結果

問題 No.2646 Cycle Maze
ユーザー matcharate12matcharate12
提出日時 2024-01-25 17:03:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,606 bytes
コンパイル時間 2,105 ms
コンパイル使用メモリ 182,628 KB
実行使用メモリ 102,272 KB
最終ジャッジ日時 2024-02-25 17:30:16
合計ジャッジ時間 16,008 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,676 KB
testcase_13 WA -
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 AC 2 ms
6,676 KB
testcase_18 WA -
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 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 424 ms
28,928 KB
testcase_26 AC 276 ms
21,248 KB
testcase_27 AC 276 ms
25,984 KB
testcase_28 AC 53 ms
7,296 KB
testcase_29 AC 456 ms
30,976 KB
testcase_30 AC 293 ms
21,888 KB
testcase_31 AC 182 ms
18,304 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 13 ms
8,064 KB
testcase_34 AC 42 ms
12,800 KB
testcase_35 AC 228 ms
19,328 KB
testcase_36 AC 20 ms
7,808 KB
testcase_37 AC 64 ms
16,128 KB
testcase_38 AC 50 ms
6,676 KB
testcase_39 AC 281 ms
21,248 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 25 ms
6,676 KB
testcase_44 AC 99 ms
11,008 KB
testcase_45 AC 298 ms
35,584 KB
testcase_46 AC 370 ms
45,824 KB
testcase_47 AC 1,426 ms
93,952 KB
testcase_48 AC 272 ms
37,888 KB
testcase_49 AC 1,386 ms
96,000 KB
testcase_50 AC 321 ms
51,200 KB
testcase_51 AC 784 ms
74,752 KB
testcase_52 AC 881 ms
79,744 KB
testcase_53 AC 1,321 ms
102,272 KB
testcase_54 AC 1,320 ms
102,272 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 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;
	//cout << t << " " << y << " " << x << endl;

	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),L;
	rep(i,H) cin >> S[i];
	L = S;

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

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