結果

問題 No.323 yuki国
ユーザー cielciel
提出日時 2019-01-21 23:53:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,535 ms / 5,000 ms
コード長 935 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 97,308 KB
実行使用メモリ 89,348 KB
最終ジャッジ日時 2023-10-13 17:35:05
合計ジャッジ時間 32,521 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1,928 ms
85,600 KB
testcase_09 AC 1,978 ms
85,448 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 1,884 ms
85,588 KB
testcase_14 AC 1,926 ms
89,348 KB
testcase_15 AC 2,003 ms
72,276 KB
testcase_16 AC 2,022 ms
85,660 KB
testcase_17 AC 2,402 ms
81,540 KB
testcase_18 AC 11 ms
4,352 KB
testcase_19 AC 1,507 ms
54,468 KB
testcase_20 AC 34 ms
5,388 KB
testcase_21 AC 2,535 ms
82,548 KB
testcase_22 AC 536 ms
25,100 KB
testcase_23 AC 2,373 ms
78,680 KB
testcase_24 AC 122 ms
10,368 KB
testcase_25 AC 2,265 ms
80,660 KB
testcase_26 AC 116 ms
10,184 KB
testcase_27 AC 159 ms
11,860 KB
testcase_28 AC 2,435 ms
85,908 KB
testcase_29 AC 2,297 ms
86,000 KB
testcase_30 AC 1 ms
4,352 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,352 KB
testcase_34 AC 1 ms
4,352 KB
testcase_35 AC 1 ms
4,352 KB
testcase_36 AC 1 ms
4,352 KB
testcase_37 AC 1 ms
4,352 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<=max(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