asterisks's blog

By asterisks, history, 2 years ago, In English

Getting wrong answer on test 2 for the following problem. 1633D - Make Them Equal

My Code 144774883 Please Help.

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

| Write comment?
»
2 years ago, # |
  Vote: I like it +4 Vote: I do not like it

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

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

I don't even understand properly your code, like there are many macros and that stuff but I'm pretty sure that there is no knapsack in there, and that was the intended way to solve it.

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

Your function for finding min no of opeartion to covert ('1' to 'm') is wrong . For m = 31 , you are getting minimum no of steps/operations as '7' but the minimum no of steps for m = '31' is '6' .

Edit :- Here is how you get 31 — [ 1 --> 2 --> 4 --> 8 --> 16 --> 21 --> 31 ] ( in 6 steps )

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

    Can you give the right approach please?

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

      You can use bfs to calculate minimum number of steps to reach B[i] from 1 or use an array to precalculate. I used an array.

      Click

      You can precalculate this before test cases. Here is my submission

»
2 years ago, # |
  Vote: I like it -9 Vote: I do not like it