1998 Canadian Computing Competition, Stage 1
Problem A: Censor
The Society for the Prevention of Profanity on the Internet has observed a growing number of chat lines on the World-Wide Web. A chat line allows a Web user to type lines of text which are transmitted to all other users. The Society is concerned about the number of four-letter words being transmitted by these chat lines and has proposed the mandatory use of software to remove all four-letter words from every transmission. Your job is to write the software to do this removal.
The input to your program consists of an integer, n, on a line by itself, followed by n lines of text. Each line of text contains words separated by spaces. Each word consists of letters of the alphabet and exactly one space separates adjacent words. Lines do not exceed 80 characters in length.
The output from your program should consist of the n lines of text, with each four-letter word replaced by four asterisks. The lines should be separated by one blank line.
2 The quick brown fox jumps over the lazy dog Now is the time for all good people to come to the aid of the party
The quick brown fox jumps **** the **** dog Now is the **** for all **** people to **** to the aid of the party
Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 01, 2008
- String Manipulation
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Note: ccc98s1.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
What does that mean?
The sample case worked with my code, but for the actual test case, I am getting all of the lines with just one getline.
As a side note, you might've noticed that even recent C/C++/Pascal submissions cannot get exactly 0.000s like many best submissions you've seen. This is because those were submitted back when the judge had a different grading system (and possibly even hardware?), so the execution times may not have been as accurate.
Even so, I am here also to try and improve my performances, not just getting the right answer (which often is way too plain to me), so I'll try not to focus too much on my own reported times and a tad more on other users best practices and interesting code.
Btw, I sincerely doubt that C or the poor Pascal can really be HUNDREDS of time faster than my good old snake.
Do you need a blank line between the last line of input and the first line of output, too?
(The judge's "screen" is infinite, so no need to worry about stuff like that)
this is so very random
**** is so **** random
finally i am done
finally i am ****
The output from your program should consists of the n lines of text, with each four-letter word replaced by four asterisks. The lines should be separated by one blank line.