Someone please take a look at the above editorial i could not understand the editorial, so please write a detailed answer. (https://atcoder.jp/contests/abc194/tasks/abc194_f)
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
Someone please take a look at the above editorial i could not understand the editorial, so please write a detailed answer. (https://atcoder.jp/contests/abc194/tasks/abc194_f)
| Name |
|---|



I think first of all you have to add the link of the problem in the description of the blog not in title .
The editorial is quiet detailed ,
I think you should write in which part of the editorial you are facing the problem , then people can help you .
Ok i will add the link in description.
so we have dp[i][j]=dp(i+1,j)*j+(16-j)*dp(i+1,j+1)
in (16-j)*dp(i+1,j+1) we are selecting any one of the 16-j digits so that the number of distinct digits has increased by one. If we select <n(string size) digits the number will always be less than N.
However if we select exactly n digits the number obtained by the above dp may be greater than N. so how are we making sure that if we select n digits number obtained is always less than n? We could make sure that we only select digits from 1 to v[i] but then we would have to keep track of which digits we have used in our string(2^16).
Okay , I got what are you saying
I think you have not noticed that in the definition of dp[i][j] they have mentioned that all the i digits of the current number is strictly lesser than that of N .
They have also added 2 bullet points for the case where all the digits are equal to N and when all the digits upto i are all 0
Basically you have to keep track of all the digits that have come in N upto i significant digit using a set
Here is a link which I think implements the approach of the editorial
Ok thanks to your implementation i got it! Basically, dp[1][1]=one less than first digit. So that we take all possible i digits lexicographicaly less than the first i digits of our string, thus we have (16-j) choices of what we want to take the next digit as the number will always be smaller and the case where the first i digits are same is treated as a special case. Thank you!
Auto comment: topic has been updated by sidakbhatia (previous revision, new revision, compare).