JDCC '17 Contest 3 S1 - <<<<3<33<333

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type

Vedant really wants the recruiters at a certain internet search company to know how much he wants to work there, so he adds a bunch of cute hearts at the end of his resume.

A cute heart is defined as one of the following:

  • <3 is a cute heart
  • <x3, where x is a cute heart
  • xy, where x and y are cute hearts

For example, <<<333, <<3<33, <3<3 and <<<<3<33<333 are all cute hearts, but <<3, <33< and 3<3< are not cute hearts.

Help Vedant figure out whether the text he added to his resume is a cute heart!


The input is a single string with no more than 10^5 characters, with each character being either < or 3.


Output <3 if the text is a cute heart, and </3 otherwise.

Sample Input 1


Sample Output 1


Explanation for Sample Input 1

All the hearts are nested correctly within each other.

Sample Input 2


Sample Output 2


Explanation for Sample Input 2

The last character, 3, is not matched with a <, so it can't be a cute heart.


There are no comments at the moment.