PROBLEM LINK:Author: Pavel Sheftelevich DIFFICULTY:Cakewalk PREREQUISITES:Adhoc, Strings PROBLEM:
QUICK EXPLANATION:
EXPLANATION:
SUBTASK 1
SUBTASK 2
Let's think for a second, do we need to consider any permutation of letters of $S$? Of course we don't to do that. Notice that if there not enough letter to form both the required prefix and the required suffix, the answer is clearly NO. On the other hand, if there are enough letters in $S$ to form the required prefix and the required suffix, the answer is YES. First, we can notice that the shortest string containing required prefix and required suffix has length $9$. This is true, because a string LTIMEMITL has length $9$ and has the required prefix and suffix. Moreover, there is no such shorter string, because the longest prefix of EMITL which is also a suffix of LTIME has length $1$. Based on this observation, there are three cases to consider. If $n = 9$ then the answer is YES if and only if S contains two L, two T, two I, two M and one E. If $n > 9$, then the answer is YES if and only if S contains at least two L, at least two T, at least two I, at least two M and at least two E. If $n < 9$, then the answer is clearly NO. The total complexity of this solution is $O(n)$, because the only thing we have to do is to count occurrences of $5$ different letters in $S$. AUTHOR'S AND TESTER'S SOLUTIONS:Author's solution can be found here.
This question is marked "community wiki".
asked 24 Oct '15, 18:57

https://www.codechef.com/viewsolution/8632174 why wrong in 2nd sub task?? answered 25 Oct '15, 14:05
It's giving YES for LTIMEMITLQ but answer is NO i.e. it is failing for case where length of string is greater than 9 and contains one E.
(25 Oct '15, 14:15)

For which test case it is wrong? https://www.codechef.com/viewsolution/8627116 answered 25 Oct '15, 14:15

please help for this solution !!! https://www.codechef.com/viewsolution/8633042 anybody its been messing up with my mind for like 1 hour !!!! save me .... answered 25 Oct '15, 15:28
It fails for the following string LTIMXMITL, because assumed in your solution that if counters for L, T, I and M are at least 2 and the length of a string is 9, then the answer is YES. You have to check the count of E also.
(25 Oct '15, 16:04)
already got it bro .!!...but thanks for your time and further clarification :D
(26 Oct '15, 17:16)

Sorry I am a noob to competitive programming and programming in general, but why wouldn't this work answered 25 Oct '15, 16:30

Your code gives a YES for LTIME and EMITL. As mentioned in the above editorial since the smallest string possible is LTIMEMITL has a length of 9 characters, all the strings which are of lengths lesser than 9 should output NO as an answer. Happy Coding :) answered 25 Oct '15, 16:46

https://www.codechef.com/viewsolution/8635535 Why this code gives WA? Please rectify my mistake. Thanks in advance. answered 25 Oct '15, 17:03
@sectumsempra_ Your code does not give any output for TIMELTIME. The output should print NO. Please check your code and try again.
(25 Oct '15, 17:09)

This time it works for all 3 example test cases but it still isn't accepting my answer can you help me? thanks answered 25 Oct '15, 17:44
@r4huln Your code still outputs "YES" for the test case LTIMETIME which should correctly output "NO". Try to improve upon your logic or read the editorial for a proper insight. :)
(25 Oct '15, 19:19)
I am sorry but did you check the old link this one outputs NO for LTIMETIME
(25 Oct '15, 19:31)

Can you please help me with this?? It was giving answer to all the test cases, still it was not accepted... https://www.codechef.com/viewsolution/8632953 answered 25 Oct '15, 17:54
@idk_anything As mentioned in the above editorial, the smallest such string possible is LTIMEMITL. The output for this should be YES while your code outputs NO. Hence the WA :)
(25 Oct '15, 19:22)

In my computer it is working but showing wrong answer in Codechef............please help me out...I am a beginner........... answered 26 Oct '15, 21:46

In my computer it is working but showing wrong answer in Codechef............please help me out...I am a beginner........... answered 26 Oct '15, 21:47

In my computer it is working but showing wrong answer in Codechef............please help me out...I am a beginner........... answered 26 Oct '15, 21:48

This is my solution in Python. It runs correctly for the test cases. But while submitting shows an error. https://www.codechef.com/viewsolution/8633170 Please help out !! answered 27 Oct '15, 16:29

@emerald_19 Check your if i==9 line, there should be "==" not "=" answered 27 Oct '15, 17:31
