Editorial for Another Contest 5 Problem 2 - Great Graffiti
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
The first observation to make here is that the answer is at most . This is because we are guaranteed to start out with some letter in DMOJ
, and we can always just add the missing letters.
With this observation, there are two approaches. One is to enumerate all scenarios where the answer is , , or - these correspond respectively to all subsequences of DMOJ
of length , , and . Another is to brute force all possible ways of inserting characters, character, and characters.
Comments
Very interesting problem. I actually only passed all test cases once I generated all the permutations from D to JJJJ and spotted what I'd missed. There were 4 scenarios that I'd not covered, which are actually mentioned above in the editorial text. As usual, me not reading fully enough! Thanks for an interesting problem!!
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
Responding to all of your concerns:
You can write your own test cases. Problems frequently do not contain complex examples and you should not expect problems to include edge cases in the examples.
The input constraints do not say anything about the order of the letters, so you should not assume that they come in any specific order.
The problem statement does not mention anything about blanks.
We will not provide the test case that you fail on. You may find it helpful that , which is the number of test cases for this problem.
There are 28 correct submissions to this problem in Python 3. There are 9 correct submissions to this problem in Python 2. Therefore, the problem is solvable in both versions of Python, so you are welcome to pick whichever version of Python you are more comfortable with.
Thanks Chika. I made some incorrect assumptions. Your answered helped.