I used that only, only once I used ascii. I have to do a lot of practice, this was only my 2nd contest after cook-off. I hope by practice, I can shorten my code. Which corner cases are you telling about?
First case where it fails is abc and aaa minimum operation required is 1 whereas your code outputs 2.(Simply select 0,1,2 and it will convert 1st string to aaa in one operation).
Another case is abc aab .Here the minimum operation is correct but the order is different .
Your code in first operation selects 0 and 1 which will make 1st string aac and in second operation your code selects 1 and 2 which means it will make it aaa which is not equal to aab.
so changing the order will make it correct i.e select 1 and 2 first(it will make abb) and then 0 and 1.(it will make aab which is equal to 2nd string).Hope that helps
In the example test case, why do you need to have the
2
3 1 2 4
3 0 1 3
Why canāt it be
2
2 1 0
2 2 4
Because all that we need to do is replace the character at position 1 with the character 0 because the position at 1 is ābā and character at position 0 is āaā.
The first case given in the quick explanation part may not be true as it is not applicable in the following example: (Ax<Bx; string is not convertible)
aab aba
Here even though a<b ie. A[1]<B[1], still i could choose the subset {2} and still convert string A to string B in two steps.
Can anyone explain this?
All solutions , the setterās, testerās, and the editorialistās solutions are correct. If they are a bit difficult (they are to me and many beginners who are yet to learn a lot) read the explanation and try to do it yourself. You can also refer others solutions now.