Remove every nested /* */ comment block from the document in a single left-to-right pass and print the remaining text unchanged.
Medium4StackStringSimulationNo attempts yetTime limit5sMemory limit512 MBGood programmers write fabulous comments. Igor is a programmer, and he likes old C-style comments written as /* ... */ blocks. He would be happiest if he could use this one comment format everywhere, in Python, in Haskell, and in HTML/XML documents.
Igor does not think this is hard to arrange. All he needs is a pre-processor that deletes every block that opens with /*, continues with comment text, and closes with */. The processed text then goes to whatever compiler or document renderer it belongs to.
Igor's pre-processor does a few extra things.
The comments the pre-processor reads nest the way brackets nest in most programming languages. A comment can sit inside another comment. For example, the code block below has one outer comment that the pre-processor removes, and that comment holds two more comments.
printf("Hello /* a comment /* a comment inside comment */
inside /* another comment inside comment */
string */ world");
After the pre-processing step it becomes:
printf("Hello world");
A comment can start anywhere in the text: inside a string "/*...*/", in the middle of a numeric constant 12/*...*/34, or inside a character escape \/*...*/n.
Written 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
Given a text, the pre-processor removes every comment-block that the rules above describe.
The input is a text document containing comment blocks delimited by /* and */. The input is always valid and follows the text specification given in the statement. The input file always ends with a newline character.
There is only one test case in this problem. First print the following line.
Case #1:
Then print the document with every comment removed the way the statement specifies. Do not remove any space or empty line that sits outside a comment.
The input program is smaller than 100k bytes.
The input program contains only these characters.
a-z, A-Z0-9~ ! @ # % ^ & * ( ) - + = : ; " ' < > , . ? | / \ { } [ ] _Igor removes comments in a single pass. He does not remove a comment block that appears only because another comment block was removed. For example,
//*no recursion*/* file header */
becomes:
/* file header */
The * character used by a /* or a */ cannot be reused by another /* or */. For example, the following is not a proper comment block.
/*/