Clean the Forum PostsProblem code: CLNFORUM |
All submissions for this problem are available.
Long ago during the Jurassic Park age, there was a company TopHunters, which used to conduct hunting competitions for the Dinosaurs around the world. Petrosaurus was believed to be the greatest hunter of that time and all other dinosaurs enjoyed watching the hunting videos posted by him in the forums ( yes, they had a website :) ).
Many Indian dinosaurs used to post in sms language in the forums and annoy others. Vexosaurus was so annoyed reading the posts with numbers used in place of letters. He decided to correct all those posts, before the forums get Rusty. Could you please code for him and replace the following words in 1st column with their corresponding words in 2nd column
|
![]() |
Lets not make this complex and just replace the words when they appear entirely as a word themselves, and not as a subpart of bigger words ( see examples for clarity ). A word is a continuous sequence of non-space characters.
Disclaimer : This is just a fictional story. Any resemblance to real persons or company or dinosaurs is purely coincidental ;)
Input
First line contains T [ number of test cases, around 50 ]. Each of the next T lines contains a sentence with not more than 100 characters [ 'a' - 'z' , '0' - '9' , space ]. There can be 2 or more continuous spaces and you have to preserve them, in the output. Input sentence will not begin or end with a space.
Output
For each test case, output the corrected sentence, in a new line.
Example
Input: 3 i 8 food b4 gr8 2 see you w8ing 1234 5678 9 Output: i ate food before great 2 see you w8ing 1234 5678 9
| Author: | rosyish |
| Date Added: | 23-02-2011 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.


Fetching successful submissions

@Yak I have executed your
@Yak
I have executed your program and it does not produce required output as mentioned in the program definition.
The roblem statement says -
"There can be 2 or more continuous spaces and you have to preserve them, in the output."
But, when I excecuted your pgm,below are the results that I got
Input:
5
i 8 food b4
gr8 2 see you w8ing
1234 5678 9
i i ii 88 8 food b48 b4
0000 848 4 4 4 4 4 4 8 8 8 8 8 99
Output:
i ate food before
great 2 see you w8ing
1234 5678 9
i i ii 88 ate food b48 before
0000 848 for for for for for for ate ate ate ate ate 99
As you see, it is not preserving the spaces. I don't know how it got accepted.
@Admin - Is our understanding wrong?
@Yak - I executed your java
@Yak - I executed your java pgm.
CodeChef submission 481114 (JAVA) plaintext list. Status: AC, problem CLNFORUM, contest . By yak (yak), 2011-03-06 15:38:25.
#include<iostream> #include<s
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
int n;
size_t pos;
const string _keys[] = {"8","w8","4","gr8","b4"};
const string _keywords[] = {"ate","wait","for","great","before"};
cin >>n;
getchar();
while(n--)
{
string str;
getline(cin,str);
for(int i=0; i<5; i++)
{
for(pos=str.find(_keys[i]); pos!=string::npos; pos=str.find(_keys[i]))
{
int p = (int)pos;
int l = _keys[i].length();
if(((str[p+l]==' ') || (str[p+l]==' ')) && ((p-1==-1)||(str[p-1]==' ')))
str.replace(p,l,_keywords[i]);
else
break;
}
}
cout<<str<<endl;
}
return(0);
}
i m nt geting it whts wrng wid the code...on my test cases it is prfctly fine bt on code chef wrong ans. can any 1 help me plz..i got fedup...
@admin: why did i get wrong
"Each of the next T lines