DEFACING - Editorial

Here there can be leading zeroes in the answer to make S contain the same number of digits as M.
So S can be 089 and the 0 can be removed while printing.

Yes, sameer47 is correct. Here I allowed leading zeros in the solution as the length of the resulting number is not greater than |M|, so it is safe. But thanks I will update the statement.

Fixed. Thanks.

Fixed. Thanks.

You print nothing for this test: 0 6

Refer to this:
http://discuss.codechef.com/answer_link/5641/

http://ideone.com/qgYrei

you can check the link. My program prints 0 for this test case.
and it is giving correct answers for all the test cases posted below

Yes, your bug is quite tricky. It is a big luck that our test data was managed to cover it. Try this test:
2
10381 16146
0 6
I know the reason but I guess you will have a lot of fun by figuring it out the bug by yourself.

Just to make sure that this time I am correct I ideoned your code against this test and it indeed prints nothing for 0 6 now.

where K and M should be prime to each other. :stuck_out_tongue:

I just want to kick myself.
had the fastest solution but could not find the mistake after spending 2 hours on it during the contest

Hmā€¦ I thought it should be clear.
max_smaller_digit[d1][d2] is either d2-1 if we can obtain d2-1 from d1 or it is smaller than d2-1,
and in this case it is obviously coincide with max_smaller_digit[d1][d2-1].
Of course, instead someone could write the trivial method:
for each pair (d1, d2) simply loop over digits starting from d2-1.
But why not code all optimally if it is possible :slight_smile:

@anton_lunyov >> I got what you have written, but I took too much time to understand :frowning: Thats why I was in the phase of sadness as to when will I be able to write such a code :smiley:

Try this test:
4987565 14398964
Your answer is 9989889,
while the correct one is 9989989.

Your program fails at the very first test from here.

Did you write this just for fun:
ā€œI have tried every test case given in posts and problemā€¦ā€
?

words are encouraging !!!
Still I stand to my wordsā€¦
ā€œit satisfies the cases that you gaveā€¦ā€ (not fun this time !!!)
run it with gcc compilerā€¦ and see

is there a problem with ā€œmemset()ā€ ā€¦ because locally it is working fine !!!

Haha. Very funny. Youā€™ve fixed the bug and changed the submission ID to that passing posted test cases.

Now the failing test is
1042216 1815366
The answer is 1098898
while your answer is 1798898,
which is completely impossible since we canā€™t make 7 from 0.

Iā€™ve also added it to the above post with tricky test cases.

7347946 12524098 --> 10999998

1 Like

I think this is correct. If wrong what is correct solution??

You last submission return different answer. You should indicate the submission ID at codechef instead of pasting the code to outside resources.

1 Like