{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"One duty Jimmy has at the ACM is to formalize the language and grammar used in texts. Part of this job is expanding contractions and certain acronyms. \r\u003cbr\u003eA contraction in English is a word or phrase formed by omitting or combining some of the sounds of a longer phrase. For example, \"don\u0027t\" is a contraction for \"do not\" and \"o\u0027clock\" comes from \"of the clock.\" \r\u003cbr\u003e\r\u003cbr\u003eAn acronym is a series of letters (or word) formed from the initial letters of a name or from combining parts of a series of words. For example, \"ACM\" for \"Association for Computing Machinery\" or \"radar\" for \"radio detecting and ranging.\" \r\u003cbr\u003e\r\u003cbr\u003eYour job is to take a list of contractions and acronyms, and expand all contractions and some acronyms in a text. "}},{"title":"Input","value":{"format":"HTML","content":"Input begins with two numbers, C \u0026lt; 50 and A \u0026lt; 50, indicating respectively the number of contractions and acronyms Jimmy must expand. The next C lines list a contraction and its formal expansion. Following will be a list of A acronyms and their expansions, each on individual lines. Both contractions and acronyms will be presented in the following format: \r\u003cbr\u003e\u003cpre\u003e \"contraction or acronym\" -\u0026gt; \"expansion\"\u003c/pre\u003e\r\u003cbr\u003eSince contractions, acronyms and expansions may contain spaces, each will be enclosed in quotation marks and be no more than 80 characters in length. Following the lists of contractions and acronyms will be a series of texts to expand. Each text will consist of lines no longer than 80 characters. No contraction or acronym will be split over multiple lines. A text will be terminated with a line consisting only of the character \u0027#\u0027.\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output each text exactly as input, except for necessary expansions. \r\u003cbr\u003eAll contractions must be fully expanded. Each contraction may appear as listed, entirely uppercase, or capitalized (first letter uppercase, remaining letters as listed). The expansion should follow the same rule; if a contraction is uppercased, the expansion should be uppercased as well. If more than one case applies, choose the earliest matching case in the list: \"as listed,\" \"uppercased,\" and \"capitalized.\" \r\u003cbr\u003e\r\u003cbr\u003eSince acronyms are useful for understanding and identifying names, only modify the first instance of an acronym in each text. An instance of an acronym must match the case exactly (\"acm\" is not an instance of \"ACM\"). The modification consists of replacing the acronym with the expansion, followed by a space, followed by the acronym in brackets. This allows the reader to connect the acronym with the fully expanded term. \r\u003cbr\u003e\r\u003cbr\u003eThe terminating line of \u0027#\u0027 should be printed after each text. If more than one expansion or acronym match can be valid, use the one which starts earlier in the text. If several begin at the same letter, use the one appearing earliest in the input lists. Use the sample below to illustrate the process. "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 2\r\n\"doesn\u0027t\" -\u0026gt; \"does not\"\r\n\"isn\u0027t\" -\u0026gt; \"is not\"\r\n\"can\u0027t\" -\u0026gt; \"cannot\"\r\n\"ACM\" -\u0026gt; \"Association for Computing Machinery\"\r\n\"CS\" -\u0026gt; \"Computing Science\"\r\nThe ACM can\u0027t solve\r\nall the problems in CS. Though large and having\r\nmany resources at its disposal, the ACM doesn\u0027t use magic. Magic isn\u0027t\r\npart of science, and hence not part of CS. Thank you for your\r\nsuggestions.\r\nSigned,\r\n\r\nACM\r\n#\r\nThe ACM doesn\u0027t like magic.\r\nIt\u0027s not that the ACM won\u0027t use it, it\u0027s\r\njust that the ACM doesn\u0027t understand magic.\r\n#\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eThe Association for Computing Machinery (ACM) cannot solve\r\nall the problems in Computing Science (CS). Though large and having\r\nmany resources at its disposal, the ACM does not use magic. Magic is not\r\npart of science, and hence not part of CS. Thank you for your\r\nsuggestions.\r\nSigned,\r\n\r\nACM\r\n#\r\nThe Association for Computing Machinery (ACM) does not like magic.\r\nIt\u0027s not that the ACM won\u0027t use it, it\u0027s\r\njust that the ACM does not understand magic.\r\n#\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cb\u003eClarifications\u003c/b\u003e\r\u003cbr\u003eProblem D: Text Formalization\r\u003cbr\u003eNo left hand side in the rules for contractions and acronyms is a prefix of any other left hand side in the rules. \r\u003cbr\u003eThe rules are not applied recursively, i.e. the result of a substitution is not a subject to further processing. "}}]}