提出 #43104090


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
string arr[505];
string s = "snuke";
bool v[505][505][5];
int dy[4] = {1,-1,0,0};
int dx[4] = {0,0,1,-1};
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin>>n>>m;
	for(int i=0; i<n; i++) cin>>arr[i];
	if(arr[0][0] !='s'){
		cout<<"No";
		return 0;
	}
	v[0][0][0] = 1;
	queue<vector<int>>q; q.push({0,0,0});
	while(!q.empty()){
		int y = q.front()[0],x = q.front()[1];
		int z = q.front()[2];
		q.pop();
		if(y == n-1 && x==m-1){
			cout<<"Yes";
			return 0;
		}
		for(int i=0; i<4; i++){
			int yy = y+dy[i];
			int xx = x+dx[i];
			if(yy<0 || xx<0 || yy>=n || xx>=m) continue;
			int zz = z+1; zz%=5;
			if(arr[yy][xx]!=s[zz]) continue;
			if(v[yy][xx][zz]) continue;
			v[yy][xx][zz] = 1;
			q.push({yy,xx,zz});
		}
	}
	cout<<"No";
}

提出情報

提出日時
問題 D - Snuke Maze
ユーザ belphegor
言語 C++ (GCC 9.2.1)
得点 400
コード長 867 Byte
結果 AC
実行時間 28 ms
メモリ 5168 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 36
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 02_random2_17.txt, 02_random2_18.txt, 02_random2_19.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 10 ms 3500 KiB
00_sample_01.txt AC 2 ms 3536 KiB
00_sample_02.txt AC 2 ms 3600 KiB
01_random_00.txt AC 2 ms 3572 KiB
01_random_01.txt AC 3 ms 3604 KiB
01_random_02.txt AC 3 ms 3792 KiB
01_random_03.txt AC 2 ms 3676 KiB
01_random_04.txt AC 2 ms 3632 KiB
01_random_05.txt AC 2 ms 3528 KiB
01_random_06.txt AC 3 ms 3648 KiB
01_random_07.txt AC 2 ms 3552 KiB
02_random2_00.txt AC 26 ms 5056 KiB
02_random2_01.txt AC 21 ms 5044 KiB
02_random2_02.txt AC 28 ms 5056 KiB
02_random2_03.txt AC 22 ms 5044 KiB
02_random2_04.txt AC 24 ms 4972 KiB
02_random2_05.txt AC 3 ms 3764 KiB
02_random2_06.txt AC 24 ms 4980 KiB
02_random2_07.txt AC 21 ms 5100 KiB
02_random2_08.txt AC 20 ms 5052 KiB
02_random2_09.txt AC 4 ms 3688 KiB
02_random2_10.txt AC 21 ms 4988 KiB
02_random2_11.txt AC 3 ms 3840 KiB
02_random2_12.txt AC 24 ms 5072 KiB
02_random2_13.txt AC 19 ms 5068 KiB
02_random2_14.txt AC 4 ms 3832 KiB
02_random2_15.txt AC 19 ms 5032 KiB
02_random2_16.txt AC 2 ms 3676 KiB
02_random2_17.txt AC 4 ms 3852 KiB
02_random2_18.txt AC 20 ms 5024 KiB
02_random2_19.txt AC 20 ms 5048 KiB
03_handmade_00.txt AC 2 ms 3576 KiB
03_handmade_01.txt AC 16 ms 5168 KiB
03_handmade_02.txt AC 16 ms 5068 KiB
03_handmade_03.txt AC 16 ms 4992 KiB
03_handmade_04.txt AC 21 ms 5048 KiB