시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 0 | 0 | 0 | 0.000% |
There are many markup notations – systems for annotating text with formatting instructions. Markleft is yet another such system. Your task is to implement it.
Markleft takes text input in which punctuation characters are used as follows:
^
characters should be converted to upper caseOne^tWo^threE
will be converted to OneTWOthreE
\
characters should have all double quotes prefixed with \
charactersPiglet \said "Hello"\
becomes Piglet said \"Hello\"
#
characters will have all embedded numbers (there will never be more than 6 digits in a number) converted to hexadecimal#Text with 31 12 and 64#
becomes Text with 1F C and 40
<
characters should be reversedThis <be reversed<odd
becomes This desrever ebodd
@
characters should be copied verbatim – ie: markup is ignored. Note that this means that there is no way of getting @
characters into the output.This is @\<<#@ verbatim
becomes This is \<<# verbatim
Markleft sections may be nested, but if so must be nested properly (like matching brackets).
^aa<bcd<ee^
becomes AADCBEE
The following is illegal because the nesting is improper.
One #reverse me ^uppercase me # and more^
Markleft sections are closed by the first validly nested markleft character. There is no nesting in this example
abc^def^ghi^jkl^mno
becomes abcDEFghiJKLmno
But nested marklefts of the same kind are possible sometimes. Usually they have little effect, but:
ab<cd^ef<gh<ij^kl<mn
becomes ablkJIGHFEdcmn
The markleft application processes innermost nested sections first
<#31#<
becomes F1
Input consists of a number of lines of “marked left” text to be formatted. Lines of input are no longer than 100 characters. Each line should be formatted independently. You may assume that lines have valid markup. The end of input is signalled by a line with just a #
character.
Lines of formatted text.
One^tWo^threE Piglet \said "Hello"\ #Text with 31 12 and 64# This <be reversed<odd This is @\<<#@ verbatim ^aa<bcd<ee^ abc^def^ghi^jkl^mno ab<cd^ef<gh<ij^kl<mn <#31#< #
OneTWOthreE Piglet said \"Hello\" Text with 1F C and 40 This desrever ebodd This is \<<# verbatim AADCBEE abcDEFghiJKLmno ablkJIGHFEdcmn F1