結果

問題 No.2411 Reverse Directions
ユーザー tailstails
提出日時 2023-08-11 23:08:15
言語 cLay
(20240104-1)
結果
TLE  
実行時間 -
コード長 1,515 bytes
コンパイル時間 3,848 ms
コンパイル使用メモリ 176,196 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-29 14:18:30
合計ジャッジ時間 7,213 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,880 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

ll h,w,k,l,r;
char s[512][512];
char z[3d5];
ll d[512][512];
ll q[1d6];

void f(ll sy,ll sx){
	d[sy][sx]=1;
	ll i=0,j=0;
	q[j++]=sy;
	q[j++]=sx;
	while(i<j){
		ll y=q[i++];
		ll x=q[i++];
		rep(a,4){
			ll y2=y-(a==0)+(a==1);
			ll x2=x-(a==2)+(a==3);
			if(y2>=0&&y2<h&&x2>=0&&x2<w&&s[y2][x2]=='.'&&!d[y2][x2]){
				d[y2][x2]=d[y][x]+1;
				q[j++]=y2;
				q[j++]=x2;
			}
		}
	}
}

{
	rd(h,w,k,l,r,s(h));
	f(h-1,w-1);
	if(r-l+1&1||h+w+k&1||!d[0][0]){
		wt("No");
		exit(0);
	}
	rep(y,h){
		rep(x,w){
			if(x+y+l&1&&d[y][x]&&d[0][0]-d[y][x]<=l-1&&d[y][x]-d[h-1][w-1]<=k-r&&(y>0&&y<h-1&&d[y-1][x]&&d[y+1][x]||x>0&&x<w-1&&d[y][x-1]&&d[y][x+1])){
				ll p=r;
				ll y2=y;
				ll x2=x;
				while(!(y2==h-1&&x2==w-1)){
					rep(a,4){
						ll y3=y2-(a==0)+(a==1);
						ll x3=x2-(a==2)+(a==3);
						if(y3>=0&&y3<h&&x3>=0&&x3<w&&d[y3][x3]==d[y2][x2]-1){
							y2=y3;
							x2=x3;
							z[p++]="UDLR"[a];
							break;
						}
					}
				}
				p=l-1;
				if(y>0&&y<h-1&&d[y-1][x]&&d[y+1][x]){
					rep(r-l+1>>1){
						z[p++]='D';
						z[p++]='U';
					}
				}else{
					rep(r-l+1>>1){
						z[p++]='R';
						z[p++]='L';
					}
				}
				d[0...511][0..511]=0;
				f(y,x);
				p=0;
				y2=0;
				x2=0;
				while(!(y2==y&&x2==x)){
					rep(a,4){
						ll y3=y2-(a==0)+(a==1);
						ll x3=x2-(a==2)+(a==3);
						if(y3>=0&&y3<h&&x3>=0&&x3<w&&d[y3][x3]==d[y2][x2]-1){
							y2=y3;
							x2=x3;
							z[p++]="UDLR"[a];
							break;
						}
					}
				}
				wt("Yes");
				wt(z);
				exit(0);
			}
		}
	}
	wt("No");
}
0