結果

問題 No.323 yuki国
ユーザー tailstails
提出日時 2015-12-16 18:09:54
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,028 bytes
コンパイル時間 1,387 ms
コンパイル使用メモリ 148,372 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 10:50:37
合計ジャッジ時間 2,799 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)

char m[60][60];
char d[60][60];
int w,h,yu;

void g(priority_queue<int>&q,int a,int y,int x,int gy,int gx){
	if(y>=0 && y<h && x>=0 && x<w){
		a+=m[y][x]==yu?1:-1;
		if(a>0||y==gy&&x==gx){
			q.push(a<<16|y<<8|x);
		}
	}
}

bool f(int a,int y,int x,int b,int gy,int gx) {
	priority_queue<int> q;
	g(q,a,y,x,gy,gx);
	rep(y,h)rep(x,w)d[y][x]=0;
	while(!q.empty()){
		int t=q.top();
		q.pop();
		a=t>>16;
		y=t>>8&255;
		x=t&255;
		if(y==gy&&x==gx&&a>=b){				
			return true;
		}
		if(d[y][x]){
			if(d[y][x]<a){
				return true;
			}
		}else{
			d[y][x]=a;
			g(q,a,y,x-1,gy,gx);
			g(q,a,y,x+1,gy,gx);
			g(q,a,y-1,x,gy,gx);
			g(q,a,y+1,x,gy,gx);
		}
	}
	return false;
}

int main() {
	int a,si,sj,b,gi,gj,b1,b2;
	cin>>h>>w>>a>>si>>sj>>b>>gi>>gj;
	if(a+si+sj+b+gi+gj&1){
		b1=b2=0;
	}else{
		rep(y,h)cin>>m[y];
		a-=m[si][sj]=='*'?1:-1;
		yu='*';
		b1=f(a,si,sj,b,gi,gj);
		yu='.';
		b2=f(b,gi,gj,a,si,sj);
	}
	cout<<(b1&&b2?"Yes":"No");
}
0