Submit | All submissions | Best solutions | Back to list |
MAIN12C - Email ID |
Everyone loves Swampy. Swampy the Alligator lives under the city and yearns for a more human like existence. One day Swampy thought to learn the intricacies of the internet. He went to a book store in SwampVille immediately and bought a book on "Basic Internet". After reading the book Swampy decided to try on some exercises. The exercise demanded Swampy to report all valid email-id's in a given free-form text string. Check output section for exact specification. Swampy lacks the intelligence of humans and therefore needs you to help him in this job. The chapter defined email-id's as a string consisting of two parts. From left to right, these are username and site-address. The username is non-empty string of minimum length 5 build from characters {a-z A-Z 0-9 . _} (excluding the brackets). The username cannot start from '.' or '_' The site-address is build of a prefix which is non-empty string build from characters {a-z A-Z 0-9} (excluding the brackets) followed by one of the following suffixes {".com", ".org", "edu", ".co.in"}. There is no space character in the email-id. The entire email-id is "username@site-address".
Input
First line of the input contains an integer T, the number of test cases. Then T test cases follow. Each test case consists of String S on a single line. S is made up of characters {a-z A-Z 0-9 ~!@#$%^&*()<>?,.} (excluding the brackets) and space character too.
Output
For each test case, print Case #X: K, where X is the test case number starting from 1, K is the number of email-id's found in S, and then K lines with email-id's found in S.
Example
Input: 2 svm11@gmail.com svm11@gmail.com svm12@gmail.co.in Output: Case #1: 1 svm11@gmail.com Case #2: 2 svm11@gmail.com svm12@gmail.co.in
Constraints: T <= 100 |S| <= 10000
Added by: | Nikunj Jain |
Date: | 2012-03-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Vaibhav Mittal |
hide comments
|
|||||
2018-01-12 18:42:23
Useful, admin's kind of problem - vaguely remember the struggle of debugging an oneliner in bash solving this years ago. Today it took 40 lines in Python and I like it more this way. Strangely the description reads quite straightforward to me while much better coders seem to be out of their game here, I actually LOLed at Tjandra's comment thinking he was trolling. Again, everyone has a different nemesis. |
|||||
2013-05-22 22:56:15 Mitch Schwartz
@Federico: Yes, the problem is not well written, but I hoped to clarify with my comment. Your concern is addressed by my sixth point, "An ID must be included as soon as it is seen, working from left to right" -- but actually neither "ab@foo.edu" nor "b@foo.edu" is valid, because the username must have at least 5 characters. But to fix your example, in "abcdef@foo.edu", since there is a match starting with the leftmost character "a", we include that match right away and never check whether there is a match starting with "b". Last edit: 2013-05-22 23:06:08 |
|||||
2013-05-22 17:22:28 Federico Lebrón
If the emails can be separated by non whitespace, then I don't think the problem is well defined. ab@foo.edu could be either an incorrect email id "a", followed by a correct "b@foo.edu", or a correct "ab@foo.edu". Last edit: 2013-05-22 17:42:38 |
|||||
2013-05-15 08:33:31 Aradhya
hahahahaha... lol in PYTH |
|||||
2013-03-11 07:47:42 mukesh tiwari
@Mitch Schwartz Thank you! You observation is really great. Helped me to solve this problem. |
|||||
2013-01-06 13:47:01 Vasanth Kumar
should the minimum length of site-address also be 5? |
|||||
2012-07-23 15:47:23 Nehal J Wani
Please tell me why am I getting WA. Sub-Id:7357850 |
|||||
2012-06-08 21:56:17 15972125841321
can i plz know where i m getting wa.... my sub id 7114274 thnks now getting tle... Last edit: 2012-06-08 23:34:10 |
|||||
2012-04-09 18:20:01 (Tjandra Satria Gunawan)(曾毅昆)
I'm getting TLE... large I/O problem... |
|||||
2012-04-05 18:52:53 Jared Deckard
My 0.44 gets 0.45-0.56 today... Did anything change? Rejudge? Last edit: 2012-04-06 19:40:29 |