My solution was a bit different, although I am too going from highest power to lower power.
Firstly, I will describe how I made the observation of answer being YES for every odd number.
I wrote a recursive DP solution to check if combination N, K is valid, this was of complexity 2^N, although this is not being used in final solution but this helped me observe that answer was YES for every odd number. Link to this recursive DP function to check if N, K is valid: DP recursive check for Snackdown R1A BINFLIP · GitHub
Now after I ran this on numbers form 1-100 I observed that it was YES for odd, then I did some dry runs for odd numbers on pen and paper and observed that if I apply flip operations from highest power from start index of 1’s segment or ending at end index of 1’s segment in case we exceed N, then we can arrive at solution.
So I maintained start and end index for 1’st segment and just updated these values on each operation, if any operation goes out of bounds of N then I just applied that operation at end of 1’s segment instead.
Link to solution: CodeChef: Practical coding for everyone
I wrote a recursive DP solution to check if combination N, K is valid, this was of complexity 2^N, although this is not being used in final solution but this helped me observe that answer was YES for every odd number.
I wrote a super trivial naive bruteforcer, which worked only up to K=17. That’s kinda very small, but still allowed me to successfully make the odd numbers observation and generate small random testcases for validating correctness of a more sophisticated solution. I actually think that this made solving problem BINFLIP much easier than EQBEAUTY (implementing a correct bruteforcer for EQBEAUTY’s small input was more tricky due to handling some corner cases).
The answer is YES for any odd K. The value of N doesn’t matter and any correct solution for N=13 K=13 will be also correct for your N=15 K=13 case. Also there is more than one way to construct a correct output, so different correct solutions may produce different output. If N=15 K=13, then my solution prints
you can get answer by using only first k characters irrespective of the value of n!!
your solution seems to depend on the value of n…try using test case :
2
10 9
15 9
your code gives two different verdicts… correct answer should be :
YES
4
8
6
6
1
The formatting of the code in your comment is broken. Could you please edit your comment to fix formatting? Or even better, just replace the pasted code by a link to your submission.