#P1770. 万能的OIH搜索

万能的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 <b> before the word and </b> after the word. As for punctuation, including it in bold or not does not matter. kkksc03 wants to use as few tag pairs (<b> </b>) 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 S1S_1, the keyword string. The second line, S2S_2, is the problem string returned by OIH.

Output Format

One line, the processed result.

Shang wang dou tmd bei ping ping an an he xie diao le.
Tian yao mie he xie, tui he xie bao ping an.  shang Wang sou suo jiu ping cha cha cha ,you       zhen       xiang!
Tian yao mie <b>he xie</b>, tui <b>he xie</b> bao <b>ping an.  shang Wang</b> sou suo jiu ping cha cha cha ,you       zhen       xiang!

Hint

  • Each Chinese character has at most 77 English letters.
  • The keywords contain at most 100100 Chinese characters.
  • The returned problem contains at most 10001000 Chinese characters.

Translated by ChatGPT 5