University of Toronto ACM-ICPC Tryouts 2013

B: A Careful Reply

Weird! A week into school, Bob has received T (1 ≤ T ≤ 100) texts in a row from some girl he's never seen before, Alice. Obviously, he's promptly checked her out on Facebook, and likes what he sees! Now, the hard part - he needs to craft some appropriate replies.

Everyone knows that the affection conveyed in a text is measured by the number of hearts it contains - in other words, the number of times it contains the string "<3". Bob certainly wants to reciprocate Alice's seemingly romantic feelings, but doesn't want to come off as overly desperate. He's decided that his response to each text should contain exactly one more heart than the received text. In fact, he doesn't really want to convey any other information, so his reply will consist of only this number of instances of the string "<3", separated by single spaces (and with no leading or trailing spaces).

After waiting the appropriate amount of time (he wouldn't want to reply too quickly, after all), it's time to make a good impression on Alice - Bob wants to determine the perfect response to each of the T texts!


Line 1: 1 integer, T

For each text:
Line 1: 1 string of at most 1000 characters, the received text


For each text, output 1 string of characters, the reply to the text.

Sample Input

hey handsome <3 :)
u busy tonite?
<3 how about sum dinner? <<33<3 luv u
plz say yes <\3

Sample Output

<3 <3
<3 <3 <3 <3

Explanation of Sample

The received texts contain 1, 0, 3, and 0 hearts, respectively. Therefore, their corresponding replies should consist of 2, 1, 4, and 1 hearts, respectively.

All Submissions
Best Solutions

Point Value: 5
Time Limit: 2.00s
Memory Limit: 64M
Added: Jul 08, 2014
Author: SourSpinach

Languages Allowed:

Comments (Search)

I've been trying to solve this problem for such a long time, but I can never figure out what's wrong with it. Please help if you wish.

Hello, I believe the problem is that you are outputting more "<3" than you are supposed to. I recommend you check your loop which is being used to output the "<3", specifically the starting value and last value for int j.

I'm not sure if this is a problem with my code or not, but when I first tried this problem, I simply got it wrong. I tweaked it a little, and it works in my eclipse not, but I get an "exception in thread" error when I try to submit it. Is this my fault?

Do not specify a package when you submit to the Judge.

Oh I missed it.

Wait. I still get the error even though I removed though I removed my package name.

Oh this one my be my codes fault

Could anyone tell me whats wrong with my code? Thanks

(admin edit: snip. code from

I'm sure many people *can* help you. It's a matter of whether anyone will. If you simply post your code (which, incidentally, is visible anyway to people who have solved the problem), then I doubt people will be inclined to help.

Somebody tell me why I was wrong???

can anyone tell me why the judge keeps on giving me a runtime error? I did this same question in SPOJ and it was all correct...

If you're still curious, your error was:
terminate called after throwing an instance of 'std::out_of_range' 
what(): basic_string::at: __n (which is 0) >= this->size() (which is 0)


The judge is not broken.