A9696 | Lecture
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first one. The words in both languages consist of lowercase English characters, each language consists of several words. For each language, all words are distinct, i.e. they are spelled differently. Moreover, the words of these languages have a one-to-one correspondence, that is, for each word in each language, there exists exactly one word in the other language having has the same meaning.
You can write down every word the professor says in either the first language or the second language. Of course, during the lecture you write down each word in the language in which the word is shorter. In case of equal lengths of the corresponding words you prefer the word of the first language.
You are given the text of the lecture the professor is going to read. Find out how the lecture will be recorded in your notes.
You know two languages, and the professor is giving the lecture in the first one. The words in both languages consist of lowercase English characters, each language consists of several words. For each language, all words are distinct, i.e. they are spelled differently. Moreover, the words of these languages have a one-to-one correspondence, that is, for each word in each language, there exists exactly one word in the other language having has the same meaning.
You can write down every word the professor says in either the first language or the second language. Of course, during the lecture you write down each word in the language in which the word is shorter. In case of equal lengths of the corresponding words you prefer the word of the first language.
You are given the text of the lecture the professor is going to read. Find out how the lecture will be recorded in your notes.
输入格式
The first line contains two integers, $n$ and $m$ ( $1<=n<=3000$ , $1<=m<=3000$ ) — the number of words in the professor's lecture and the number of words in each of these languages.
The following $m$ lines contain the words. The $i$ -th line contains two strings $a_{i}$ , $b_{i}$ meaning that the word $a_{i}$ belongs to the first language, the word $b_{i}$ belongs to the second language, and these two words have the same meaning. It is guaranteed that no word occurs in both languages, and each word occurs in its language exactly once.
The next line contains $n$ space-separated strings $c_{1},c_{2},...,c_{n}$ — the text of the lecture. It is guaranteed that each of the strings $c_{i}$ belongs to the set of strings ${a_{1},a_{2},...\ a_{m}}$ .
All the strings in the input are non-empty, each consisting of no more than $10$ lowercase English letters.
The following $m$ lines contain the words. The $i$ -th line contains two strings $a_{i}$ , $b_{i}$ meaning that the word $a_{i}$ belongs to the first language, the word $b_{i}$ belongs to the second language, and these two words have the same meaning. It is guaranteed that no word occurs in both languages, and each word occurs in its language exactly once.
The next line contains $n$ space-separated strings $c_{1},c_{2},...,c_{n}$ — the text of the lecture. It is guaranteed that each of the strings $c_{i}$ belongs to the set of strings ${a_{1},a_{2},...\ a_{m}}$ .
All the strings in the input are non-empty, each consisting of no more than $10$ lowercase English letters.
输出格式
Output exactly $n$ words: how you will record the lecture in your notebook. Output the words of the lecture in the same order as in the input.
输入输出样例
输入 #1
4 3 codeforces codesecrof contest round letter message codeforces contest letter contest
输出 #1
codeforces round letter round
输入 #2
5 3 joll wuqrd euzf un hbnyiyc rsoqqveh hbnyiyc joll joll euzf joll
输出 #2
hbnyiyc joll joll un joll
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted