結果

問題 No.323 yuki国
ユーザー cielciel
提出日時 2015-12-18 04:09:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,097 ms / 5,000 ms
コード長 930 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 83,944 KB
実行使用メモリ 93,336 KB
最終ジャッジ日時 2023-10-09 06:24:31
合計ジャッジ時間 40,521 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2,136 ms
85,604 KB
testcase_09 AC 2,267 ms
85,604 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2,097 ms
85,296 KB
testcase_14 AC 2,135 ms
89,308 KB
testcase_15 AC 2,677 ms
72,216 KB
testcase_16 AC 2,950 ms
93,260 KB
testcase_17 AC 3,379 ms
81,476 KB
testcase_18 AC 13 ms
4,384 KB
testcase_19 AC 1,728 ms
54,752 KB
testcase_20 AC 33 ms
5,364 KB
testcase_21 AC 3,528 ms
82,908 KB
testcase_22 AC 645 ms
25,052 KB
testcase_23 AC 4,097 ms
93,336 KB
testcase_24 AC 141 ms
10,232 KB
testcase_25 AC 3,227 ms
80,640 KB
testcase_26 AC 135 ms
10,252 KB
testcase_27 AC 203 ms
12,708 KB
testcase_28 AC 3,125 ms
86,148 KB
testcase_29 AC 3,060 ms
86,064 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <map>
using namespace std;

typedef struct{
	int x;
	int y;
}dir;
const dir D[]={
	{0,-1},{0,1},{-1,0},{1,0}
};

int main(){
	int H,W,A,Sx,Sy,B,Gx,Gy;
	cin>>H>>W>>A>>Sy>>Sx>>B>>Gy>>Gx;
	vector<string>v(H);
	for(int i=0;i<H;i++)cin>>v[i];
	queue<tuple<int,int,int>>q;
	q.emplace(Sx,Sy,A);
	map<tuple<int,int,int>,int>depth={ {make_tuple(Sx,Sy,A),0} };
	for(;!q.empty();){
		auto cur=q.front();q.pop();
		int cx=get<0>(cur),cy=get<1>(cur),cw=get<2>(cur);
		for(auto &d:D){
			if(0<=cx+d.x&&cx+d.x<W && 0<=cy+d.y&&cy+d.y<H){
				int w=cw+(v[cy+d.y][cx+d.x]=='*' ? 1 : -1);
				if(1<=w && w<=A+B+H+W){
					if(cx+d.x==Gx && cy+d.y==Gy && w==B){
						cout<<"Yes"<<endl;
						return 0;
					}
					auto nxt=make_tuple(cx+d.x,cy+d.y,w);
					if(depth.find(nxt)==depth.end()){
						q.push(nxt);
						depth[nxt]=depth[cur]+1;
					}
				}
			}
		}
	}
	cout<<"No"<<endl;
}
0