시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
5 초 | 512 MB | 40 | 21 | 17 | 65.385% |
Good programmers write fabulous comments. Igor is a programmer and he likes the old C-style comments in /* ... */
blocks. For him, it would be ideal if he could use this style as a uniform comment format for all programming languages or even documents, for example Python, Haskell or HTML/XML documents.
Making this happen doesn't seem too difficult to Igor. What he will need is a comment pre-processor that removes all the comment blocks in /*
, followed by comment text, and by another */
. Then the processed text can be handed over to the compiler/document renderer to which it belongs—whatever it is.
Igor's pre-processor isn't quite that simple, though. Here are some cool things it does:
printf("Hello /* a comment /* a comment inside comment */ inside /* another comment inside comment */ string */ world");After the pre-process step, it becomes:
printf("Hello world");
"/*...*/"
, a constant number 12/*...*/34
or even in a character escape \/*...*/n
Or more formally:
text: text-piece text-piece remaining-text text-piece: char-sequence-without-/* empty-string remaining-text: comment-block text comment-block: /* comment-content */ comment-content: comment-piece comment-piece remaining-comment comment-piece: char-sequence-without-/*-or-*/ empty-string remaining-comment: comment-block comment-content char: letters digits punctuations whitespaces
Our pre-processor, given a text
, removes all comment-block
instances as specified.
A text document with comment blocks in /*
and */
. The input file is valid. It follows the specification of text
in the problem statement. The input file always terminates with a newline symbol.
We only have one test case for this problem. First we need to output the following line.
Case #1:
Then, print the document with all comments removed, in the way specified in the problem statements. Don't remove any spaces or empty lines outside comments.
The large input contains a program of less than 100k bytes.
The input program contains only:
a-z, A-Z,
0-9
~ ! @ # % ^ & * ( ) - + = : ; " ' < > , . ? | / \ { } [ ] _
//*no recursion*/* file header ***********/************ * Sample input program * **********/************* */ int spawn_workers(int worker_count) { /* The block below is supposed to spawn 100 workers. But it creates many more. Commented until I figure out why. for (int i = 0; i < worker_count; ++i) { if(!fork()) { /* This is the worker. Start working. */ do_work(); } } */ return 0; /* successfully spawned 100 workers */ } int main() { printf("Hello /*a comment inside string*/ world"); int worker_count = 0/*octal number*/144; if (spawn_workers(worker_count) != 0) { exit(-1); } return 0; }
Case #1: /* file header ************************ */ int spawn_workers(int worker_count) { return 0; } int main() { printf("Hello world"); int worker_count = 0144; if (spawn_workers(worker_count) != 0) { exit(-1); } return 0; }
//*no recursion*/* file header */should generate:
/* file header */
*
character in any /*
or /*
cannot be re-used in another /*
or */
. For example the following does NOT form a proper comment block
/*/
Contest > Google > Google's Coding Competitions > Google of Greater China Test for New Grads of 2014 > Round B China New Grad Test 2014 E2번
Contest > Google > Kick Start > Google Kick Start 2013 > Round B B2번