Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Feb 13, 2022
1 parent 2553ffa commit a3553d4
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
```
其中上式里的available plans比较复杂。因为slot里面可以放0个或者1个或者2个数字,所以需要在state所代表的数字集合里面任意挑选0个、1个、2个数字的组合,这个组合的大小可能会有C(18,2)的级别。综上三层循环的总复杂度会是:```9*(2^18)*C(18,2)```,这是1e8数量级的数字,会TLE。

第二种方法,我们用三进制数state来表示所有slots的状态(三进制数的每个bit表示该slot里面已经装了0个、1个或2个数字)。于是dp[i][state]表达的是:用完第i个数字、配对了state所表示的slots时,所得的最大价值。所以核心代码大致会是:
第二种方法,我们用三进制数state来表示所有slots的匹配状态(三进制数的每个bit表示该slot里面已经装了0个、1个或2个数字)。于是dp[i][state]表达的是:用完第i个数字、配对了state所表示的slots时,所得的最大价值。所以核心代码大致会是:
```
for (int i=0; i<nums.size(); i++)
for (int state=0; state<pow(3, numSlots); state++)
Expand Down

0 comments on commit a3553d4

Please sign in to comment.