sidakbhatia's blog

By sidakbhatia, history, 4 years ago, In English

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)

  • Vote: I like it
  • -23
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it +10 Vote: I do not like it

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 .

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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).

    • »
      »
      »
      4 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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

      • »
        »
        »
        »
        4 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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!

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by sidakbhatia (previous revision, new revision, compare).