結果

問題 No.323 yuki国
ユーザー NekosyndromeNekosyndrome
提出日時 2015-12-16 00:12:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 203 ms / 5,000 ms
コード長 1,353 bytes
コンパイル時間 1,431 ms
コンパイル使用メモリ 153,336 KB
実行使用メモリ 14,068 KB
最終ジャッジ日時 2023-09-10 21:13:47
合計ジャッジ時間 5,372 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
13,776 KB
testcase_01 AC 5 ms
13,868 KB
testcase_02 AC 5 ms
13,872 KB
testcase_03 AC 8 ms
14,028 KB
testcase_04 AC 6 ms
13,756 KB
testcase_05 AC 6 ms
14,028 KB
testcase_06 AC 5 ms
13,748 KB
testcase_07 AC 5 ms
13,772 KB
testcase_08 AC 122 ms
13,796 KB
testcase_09 AC 125 ms
13,768 KB
testcase_10 AC 6 ms
13,740 KB
testcase_11 AC 5 ms
13,912 KB
testcase_12 AC 5 ms
13,808 KB
testcase_13 AC 127 ms
13,760 KB
testcase_14 AC 125 ms
13,872 KB
testcase_15 AC 42 ms
13,800 KB
testcase_16 AC 121 ms
13,804 KB
testcase_17 AC 163 ms
13,960 KB
testcase_18 AC 45 ms
13,820 KB
testcase_19 AC 86 ms
13,772 KB
testcase_20 AC 197 ms
13,784 KB
testcase_21 AC 200 ms
13,788 KB
testcase_22 AC 203 ms
13,788 KB
testcase_23 AC 200 ms
13,816 KB
testcase_24 AC 50 ms
13,956 KB
testcase_25 AC 49 ms
13,780 KB
testcase_26 AC 162 ms
13,856 KB
testcase_27 AC 166 ms
13,868 KB
testcase_28 AC 155 ms
13,860 KB
testcase_29 AC 143 ms
13,908 KB
testcase_30 AC 6 ms
13,780 KB
testcase_31 AC 5 ms
13,884 KB
testcase_32 AC 5 ms
13,980 KB
testcase_33 AC 5 ms
13,760 KB
testcase_34 AC 6 ms
13,896 KB
testcase_35 AC 5 ms
14,068 KB
testcase_36 AC 6 ms
13,744 KB
testcase_37 AC 5 ms
13,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 55
#define MT make_tuple
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
typedef tuple<int,int,int> T;
int n,m;
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

int sx,sy,sz;
int ex,ey,ez;
bool vis[M][M][3505];
char mp[M][M];
bool out(int x,int y)
{
	return x<=0 || y<=0 || x>n || y>m;
}
int main()
{
	int x,y,z;
	int nx,ny,nz;
	while(~scanf("%d %d",&n,&m))
	{
		RI(sz,sx,sy); sx++; sy++;
		RI(ez,ex,ey); ex++; ey++;
		REP(i,1,n) scanf("%s", mp[i]+1);

		MSET(vis,false);
		queue<T> q;
		vis[sx][sy][sz] = true;
		q.push(MT(sx,sy,sz));
		while(!q.empty())
		{
			tie(x,y,z) = q.front();
			q.pop();

			REP(i,0,3)
			{
				nx = x+dx[i];
				ny = y+dy[i];
				if(out(nx,ny)) continue;
				nz = z;
				if(mp[nx][ny]=='*') nz++;
				else nz--;

				if(nz<=0 || nz>3500) continue;

				if(vis[nx][ny][nz]) continue;

				vis[nx][ny][nz] = true;
				q.push(MT(nx,ny,nz));
			
			}
		}

		puts(vis[ex][ey][ez] ? "Yes":"No");
	}
	return 0;
}
0