結果
問題 |
No.2411 Reverse Directions
|
ユーザー |
|
提出日時 | 2023-08-11 22:35:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,066 bytes |
コンパイル時間 | 404 ms |
コンパイル使用メモリ | 82,332 KB |
実行使用メモリ | 104,188 KB |
最終ジャッジ日時 | 2024-11-18 17:28:10 |
合計ジャッジ時間 | 6,825 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 RE * 1 |
other | AC * 9 WA * 6 RE * 14 |
ソースコード
h,w,k,l,r=map(int,input().split()) X=[] for i in range(h): s=input() S=[str(c) for c in s] X.append(S) if r==k or (r+l)%2==0 or k%2!=0: print("No") exit() X[0][0]=0 ex=[[0,0]] point=0 while point!=len(ex): II=ex[point] now=X[II[0]][II[1]] for I in [[1,0],[-1,0],[0,1],[0,-1]]: if 0<=II[0]+I[0]<h and 0<=II[1]+I[1]<w: if X[II[0]+I[0]][II[1]+I[1]]==".": X[II[0]+I[0]][II[1]+I[1]]=now+1 ex.append([II[0]+I[0],II[1]+I[1]]) point+=1 if X[-1][-1]>k-r+l-1: print("No") exit() ans="" #print(X) II=[h-1,w-1] point=X[-1][-1] VM=["","L","","U","D","","R"] for i in reversed(range(point)): for I in [[1,0],[-1,0],[0,1],[0,-1]]: if 0<=II[0]+I[0]<h and 0<=II[1]+I[1]<w: if X[II[0]+I[0]][II[1]+I[1]]==i: II=[II[0]+I[0],II[1]+I[1]] key=I[0]+3*I[1] #print(key,I) ans=ans+VM[key] break print("Yes") print(ans[:l],end="") print((ans[l]+VM[-VM.index(ans[l])])*((k-len(ans))//2),end="") print(ans[l:])