結果

問題 No.323 yuki国
ユーザー cielciel
提出日時 2015-12-18 04:08:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 930 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 83,564 KB
実行使用メモリ 221,704 KB
最終ジャッジ日時 2023-10-14 13:46:46
合計ジャッジ時間 7,825 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,700 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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