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)
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 151 |
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)
Название |
---|
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).