ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1050. Preparing an Article

Hint: use Java (+)
Posted by ASK 23 Mar 2010 20:49
It is possible to get AC with a 10-lines program. Simply use regular expressions:

Q = "(?<!\\\\)\"" for " which is not preceded by \

".*?(?:\n\r?\n|\\\\par(?![A-Za-z])|$)" for paragraph (note \r)

For each paragraph you get with Scanner.findWithinHorizon, do replaceAll matching Q+"(.*?)"+Q with "``$1''" and then replaceFirst Q with an empty string.

Btw, the real TeX parsing is much more complicated, e.g., \\par would not end a paragraph.