Editorial for TLE '16 Contest 8 P2 - Dank Meme


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: ZQFMGB12

Another straightforward implementation problem. This problem can be done especially quickly using certain Python methods.

One method of implementing a solution is to push the individual binary digits of the number into a stack until that number is 0. Keep in mind that by doing this, we need to handle the case if the number is 0, which can be done with a rare "do-while" loop. Afterward, pop the stack and replace 1s with dank and 0s with meme. Make sure that you do not forget to include the trailing zeros.

Time Complexity: \mathcal{O}(T \log N)


Comments


  • 1
    OneYearOld  commented on Oct. 27, 2020, 7:53 p.m.

    I discovered that you get 50/100 if you do not handle the corner case of 0.