Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a7f8569

Browse files
Create Readme.md
1 parent e2e8080 commit a7f8569

File tree

1 file changed

+11
-0
lines changed
  • Dynamic_Programming/3665.Twisted-Mirror-Path-Count

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### 3665.Twisted-Mirror-Path-Count
2+
3+
考虑到对于镜子而言,左边入只能下边出,上边入只能右边出,所以我们需要在设计dp状态时考虑入射方向。令dp[i][j][d]表示以d方向进入(i,j)时的路径数量。令d=0表示向下,d=1表示向右。
4+
5+
考虑从(i-1,j)往下进入(i,j)。如果(i-1,j)是普通的格子,那么就有`dp[i][j][0]+=dp[i-1][j][0]+dp[i-1][j][1]`.如果(i-1,j)是镜子,那么只能是向右进入镜子的路径才能往下进入(i,j),即`dp[i][j][0]+=dp[i-1][j][1]`
6+
7+
同理考虑从(i,j-1)往右进入(i,j),更新`dp[i][j][1]`.
8+
9+
最终输出`dp[m-1][n-1][0]+`dp[m-1][n-1][1]`.
10+
11+
注意初始条件(0,0),可以任意设置`dp[0][0][0]=1`或者`dp[0][0][1]=1`

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /