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 3. This is
because we are guaranteed to start out with some letter in DMOJ
, and we
can always just add the three 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 0 characters, 1 character, and 2
characters.
Comments
This comment is hidden due to too much negative feedback. Click here to view it.
This comment is hidden due to too much negative feedback. Click here to view it.
This comment is hidden due to too much negative feedback. Click here to view it.
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.