32 lines
730 B
C++
32 lines
730 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
map<string, string> dict;
|
|
int main() {
|
|
int N;
|
|
cin >> N;
|
|
while (N--) {
|
|
string word1, word2;
|
|
cin >> word1 >> word2;
|
|
dict[word1] = word2;
|
|
}
|
|
string content, word = "";
|
|
cin >> content;
|
|
content += "\n";
|
|
|
|
for (int i = 0; i < content.size(); i++) {
|
|
if (content[i] >= 'a' && content[i] <= 'z')
|
|
word += content[i];
|
|
else { // 遇到符号,就停止下来看看刚才是不是拼接出了新的单词
|
|
if (word != "") {
|
|
if (dict.count(word))
|
|
cout << dict[word];
|
|
else
|
|
cout << "UNK";
|
|
word = "";
|
|
}
|
|
// 输出符号
|
|
cout << content[i];
|
|
}
|
|
}
|
|
return 0;
|
|
} |