# 1122 程式設計實習IV (資訊一乙) Week02 作業 ## 1. Slogan Learning of Princess --- ## 題目敘述 Prince Macaw is flying here and there and searching for food. Her Princess is waiting for him at home. But he stopped when he was flying near Shahbag. He saw millions of people gathered there for only one demand- death sentence of war crimes. They were giving slogans. If you are not familiar with slogans let me tell you, slogan has two parts. One part of the slogan is yelled by the leader and the rest part is chorused from the mass people. For example, when the leader says — “tomar amar thikana” then other say “padma meghna jomuna”. Some of the slogans are listed below- ![image](https://hackmd.io/_uploads/B1gyGKyM0.png) Prince also joined with this mass people. When it was too late, Princess got worried about Prince. So she also went out. After some while, she found Prince on a tree at Shahbag yelling slogans in strong voice. Instead of getting mad, Princess asked Prince what are the slogans. So Prince told her a few slogans, first line and corresponding second line. So Princess got prepared. Given the list of the slogans and also the first lines Princess going to hear, print out the second line of the slogans. --- ### 題目輸入 First line contains number of slogans, $N$ ($0 < N \le 20$) Prince is going to teach Princess. Hence follows $N$ pairs of lines. First line of the pair contains first line of a slogan and the second line of the pair is corresponding second line of the slogan. Then another positive integer $Q$ will be given ($Q \le 100$). Hence follows $Q$ lines. Each line contains first line of a slogan. You may assume that the slogans will contain lower case English alphabet and/or space. Both the lines of slogan will contain at least one alphabet. No two first lines in the Princes slogan list will be same. Each slogan will be at most $100$ characters long. All of the query first line will be in Princes list. --- ## 題目輸出 For each of the first line of the slogan, you need to print out corresponding second line. --- ## 範例輸入 ``` 3 ko te kader molla tui rajakar tui rajakar tumi ke ami ke garo chakma bangali jalo re jalo agun jalo 2 jalo re jalo ko te kader molla ``` --- ## 範例輸出 ``` agun jalo tui rajakar tui rajakar ``` --- ## 2. Common Permutation --- ### 題目敘述 Given two strings of lowercase letters, $a$ and $b$, print the longest string $x$ of lowercase letters such that there is a permutation of $x$ that is a subsequence of $a$ and there is a permutation of $x$ that is a subsequence of $b$. --- ### 題目輸入 Input file contains several lines of input. Consecutive two lines make a set of input. That means in the input file line $1$ and $2$ is a set of input, line $3$ and $4$ is a set of input and so on. The first line of a pair contains $a$ and the second contains $b$. Each string is on a separate line and consists of at most $1000$ lowercase letters. --- ### 題目輸出 For each set of input, output a line containing $x$. If several $x$ satisfy the criteria above, choose the first one in alphabetical order. --- ### 範例輸入 ``` pretty women walking down the street ``` --- ### 範例輸出 ``` e nw et ``` --- ## 作業繳交方式 - 交至ilearn作業繳交區 - 原始碼檔名以 學號_題號.c 或 學號_題號.cpp 命名 (example. D1109070_01.c 或是 D1109070_01.cpp) - 兩題分兩個檔案上傳 - 在OJ上面有可以讓你檢視是否正確的作答區 - 名稱: [112 (資訊一乙) 程式設計IV Week02 作業] - 密碼: VMWare