Emoticons
InterviewTime limit3sMemory limit1024 MB
Given a message, replace every occurrence of one character with another (or none), convert emoticons from the left, and report the minimum and maximum resulting lengths.
- Level
Medium4 of 10
- Topics
- Brute force, String, Simulation
- Solved
- No attempts yet
Problem
Emma is a college student who regularly posts messages on her favorite social media. The platform supports several emoticons, which are pictorial representations of facial expressions made from characters.
One day she noticed that some emoticons in her messages were automatically converted into the matching emojis by the platform.
For example, if she sends the message Hello ;-), the post shows Hello followed by a wink emoji.
If two or more emoticons overlap in a message, the system always converts the leftmost emoticon first.
The complete list of emoticons supported by the platform is below.
She always uses only the visible characters and the space character. The visible characters are the digits 0123456789, the uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ, the lowercase letters abcdefghijklmnopqrstuvwxyz, and the symbols !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~.
Today, just before posting, she accidentally replaced all occurrences of one character in her message with another character. The replacement character can be a space. She might also have replaced a character with the same character, which changes nothing.
Now she wants to know the length of the message after the platform converts emoticons into emojis, where each emoji counts as one character. Find the minimum and maximum possible message lengths.
Input
The input contains Emma's original text, before she replaced any characters, on one line. The text has at most 100 characters, made of the visible ASCII characters listed above and the space character.
The text is not empty, and its first and last characters are visible characters.
Output
Print two integers, the minimum and the maximum possible message lengths after emoticons are converted into emojis, separated by a space.







