結果

問題 No.323 yuki国
ユーザー chocoruskchocorusk
提出日時 2018-12-21 16:59:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 340 ms / 5,000 ms
コード長 1,324 bytes
コンパイル時間 981 ms
コンパイル使用メモリ 103,544 KB
実行使用メモリ 13,368 KB
最終ジャッジ日時 2023-10-26 01:33:13
合計ジャッジ時間 6,093 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
13,260 KB
testcase_01 AC 9 ms
13,260 KB
testcase_02 AC 8 ms
13,260 KB
testcase_03 AC 12 ms
13,260 KB
testcase_04 AC 9 ms
13,260 KB
testcase_05 AC 9 ms
13,260 KB
testcase_06 AC 9 ms
13,260 KB
testcase_07 AC 9 ms
13,260 KB
testcase_08 AC 168 ms
13,340 KB
testcase_09 AC 166 ms
13,340 KB
testcase_10 AC 9 ms
13,260 KB
testcase_11 AC 9 ms
13,260 KB
testcase_12 AC 9 ms
13,260 KB
testcase_13 AC 175 ms
13,340 KB
testcase_14 AC 173 ms
13,340 KB
testcase_15 AC 51 ms
13,348 KB
testcase_16 AC 166 ms
13,356 KB
testcase_17 AC 217 ms
13,348 KB
testcase_18 AC 57 ms
13,336 KB
testcase_19 AC 121 ms
13,348 KB
testcase_20 AC 338 ms
13,368 KB
testcase_21 AC 340 ms
13,368 KB
testcase_22 AC 337 ms
13,368 KB
testcase_23 AC 324 ms
13,368 KB
testcase_24 AC 68 ms
13,348 KB
testcase_25 AC 64 ms
13,348 KB
testcase_26 AC 232 ms
13,348 KB
testcase_27 AC 250 ms
13,348 KB
testcase_28 AC 227 ms
13,340 KB
testcase_29 AC 220 ms
13,340 KB
testcase_30 AC 9 ms
13,260 KB
testcase_31 AC 9 ms
13,260 KB
testcase_32 AC 9 ms
13,260 KB
testcase_33 AC 8 ms
13,260 KB
testcase_34 AC 8 ms
13,260 KB
testcase_35 AC 8 ms
13,260 KB
testcase_36 AC 8 ms
13,260 KB
testcase_37 AC 9 ms
13,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
int h, w;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
bool check(int x, int y){
  if(x<0 || x>=h || y<0 || y>=w) return false;
  return true;
}
int main()
{
	cin>>h>>w;
	int a, b, sx, sy, gx, gy;
	cin>>a>>sx>>sy;
	cin>>b>>gx>>gy;
	string m[50];
	for(int i=0; i<h; i++) cin>>m[i];
	queue<Pi> que;
	bool ok[50][50][4001]={};
	ok[sx][sy][a]=1; que.push({{sx, sy}, a});
	while(!que.empty()){
		Pi p=que.front(); que.pop();
		int x=p.first.first, y=p.first.second, t=p.second;
		for(int k=0; k<4; k++){
			int x1=x+dx[k], y1=y+dy[k];
			if(!check(x1, y1)) continue;
			if(m[x1][y1]=='.'){
				if(t==1) continue;
				if(ok[x1][y1][t-1]) continue;
				ok[x1][y1][t-1]=1;
				que.push({{x1, y1}, t-1});
			}else{
				if(t>=4000) continue;
				if(ok[x1][y1][t+1]) continue;
				ok[x1][y1][t+1]=1;
				que.push({{x1, y1}, t+1});
			}
		}
	}
	if(ok[gx][gy][b]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
0