Editorial for DMPG '19 B3 - Contact
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.
Author:
If we have sent at least consecutive messages, then SSS...SS
(which is of length ) will appear as a substring of the input string.
Thus it suffices to check if this string is contained.
Time Complexity: , where is the total number of messages sent.
This can be optimized to by finding the number of consecutive S
s for each prefix. Let be the smallest index such that S
. Then if S
, and 0
otherwise. Print Spamming
if for any , and All good
otherwise.
Comments