P1770 The Universal OIH Search
Background
The following are all true stories.
OIH (Oi in hand ) is Luogu’s official strategic partner.
Luogu’s problem search feature (see the search box above) and its online IDE are both powered by OIH.
OIH’s search is very powerful. Its large database contains $8000+$ problems from mainstream domestic and international OJs. With just a few words (problem title, description, or even testdata), it can quickly find the source of a problem (the killer of “modified problems”).
In the future, OIH will also index solution write-ups from across the web (on the order of ten thousand). With just the problem name, you will be able to find its solutions.
OIH’s goal is to build an app suitable for OIers. Although OIH is not an OJ, its auxiliary features can bring great convenience to OIers. If you have any ideas, please @soha (the author of OIH).
Description
After multiple negotiations, kkksc03 finally obtained access to the OIH search API, sent a query request to the OIH server, and received a problem in response.
The query keywords form a sentence composed of Chinese characters (we replace them with their pinyin), spaces (there is a space between every Chinese character), and half-width punctuation. The returned problem string has the same format. kkksc03 wants to bold certain words in the problem. A “word” means two or more consecutive Chinese characters. For example, `tao tao` and `zhai ping guo` are words, while `hao` and `ni,hao` are not. If a word that appears in the problem also appears as a word in the keywords, then bold it. To bold, add `` before the word and `` after the word. As for punctuation, including it in bold or not does not matter. kkksc03 wants to use as few tag pairs (`` ``) as possible, and, subject to that, minimize the number of characters enclosed by each pair of tags.
Input Format
Two lines. The first line is a string $S_1$, the keyword string. The second line, $S_2$, is the problem string returned by OIH.
Output Format
One line, the processed result.
Explanation/Hint
- Each Chinese character has at most $7$ English letters.
- The keywords contain at most $100$ Chinese characters.
- The returned problem contains at most $1000$ Chinese characters.
Translated by ChatGPT 5