結果

問題 No.323 yuki国
ユーザー kotatsugame
提出日時 2020-03-02 23:43:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 76,504 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-10-13 21:23:47
合計ジャッジ時間 3,375 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
using namespace std;
int H,W;
int sa,sx,sy,ga,gx,gy;
string M[50];
bool vis[50][50][2000];
int d[4]={1,0,-1};
main()
{
	cin>>H>>W;
	cin>>sa>>sx>>sy>>ga>>gx>>gy;
	sa--,ga--;
	for(int i=0;i<H;i++)cin>>M[i];
	vis[sx][sy][sa]=true;
	queue<pair<pair<int,int>,int> >P;
	P.push(make_pair(make_pair(sx,sy),sa));
	while(!P.empty())
	{
		int x=P.front().first.first,y=P.front().first.second;
		int a=P.front().second;
		P.pop();
		for(int r=0;r<4;r++)
		{
			int tx=x+d[r],ty=y+d[r^1];
			if(tx<0||ty<0||tx>=H||ty>=W)continue;
			int ta=a+(M[tx][ty]=='*'?1:-1);
			if(ta<0||ta>=2000)continue;
			if(!vis[tx][ty][ta])
			{
				vis[tx][ty][ta]=true;
				P.push(make_pair(make_pair(tx,ty),ta));
			}
		}
	}
	cout<<(vis[gx][gy][ga]?"Yes":"No")<<endl;
}
0