What Are You Talking About

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others)
Total Submission(s): 16042    Accepted Submission(s): 5198

Problem Description
Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate the history book
into English. Can you help him?
 

Input
The problem has only one test case, the test case consists of two parts, the dictionary part and the book part. The dictionary part starts with a single line contains a string "START", this string should be ignored, then some lines
follow, each line contains two strings, the first one is a word in English, the second one is the corresponding word in Martian's language. A line with a single string "END" indicates the end of the directory part, and this string should be ignored. The book
part starts with a single line contains a string "START", this string should be ignored, then an article written in Martian's language. You should translate the article into English with the dictionary. If you find the word in the dictionary you should translate
it and write the new word into your translation, if you can't find the word in the dictionary you do not have to translate it, and just copy the old word to your translation. Space(' '), tab('\t'), enter('\n') and all the punctuation should not be translated.
A line with a single string "END" indicates the end of the book part, and that's also the end of the input. All the words are in the lowercase, and each word will contain at most 10 characters, and each line will contain at most 3000 characters.
 

Output
In this problem, you have to output the translation of the history book.
 

Sample Input

START
from fiwo
hello difh
mars riwosf
earth fnnvk
like fiiwj
END
START
difh, i'm fiwo riwosf.
i fiiwj fnnvk!
END
 

Sample Output

hello, i'm from mars.
i like earth!

Hint

Huge input, scanf is recommended.

 

Author
Ignatius.L
 

Recommend
We have carefully selected several similar problems for you:  1800 1671 

pid=1298">1298 

pid=1026">1026 1016 

 

直接map.

#include<cstring>
#include<cstdio>
#include<iostream>
#include<map>
#include<string> using namespace std; int main() {
//freopen("test.in","r",stdin);
string a,b;
map<string,string>mp;
while(1) {
cin>>a;
if(a=="START")continue;
if(a=="END")break;
cin>>b;
mp[b]=a;
}
char s[1010];
getchar();
while(1) {
gets(s);
if(strcmp(s,"START")==0)continue;
if(strcmp(s,"END")==0)break;
int len=strlen(s);
char p[40];
int l=0;
map<string,string>::iterator it;
for(int i=0; i<len; i++) {
if(s[i]<'a'||s[i]>'z') {
if(l!=0) {
p[l]='\0';
if(mp[p]!="")
cout<<mp[p];
else
printf("%s",p);
}
printf("%c",s[i]);
l=0;
} else {
p[l++]=s[i];
}
}
cout<<endl;
}
return 0;
}

hdu 1075 What Are You Talking About(map)的更多相关文章

  1. HDU 1075 What Are You Talking About(Trie的应用)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  2. hdu 1075 (map)

    http://acm.hdu.edu.cn/showproblem.php?pid=1075 What Are You Talking About Time Limit: 10000/5000 MS ...

  3. HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)

    Problem Description Ignatius is so lucky that he met a Martian yesterday. But he didn't know the lan ...

  4. HDU 1075 What Are You Talking About (stl之map映射)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  5. HDU 1075 字符串映射(map)

    Sample InputSTARTfrom fiwohello difhmars riwosfearth fnnvklike fiiwjENDSTARTdifh, i'm fiwo riwosf.i ...

  6. hdu 1075 What Are You Talking About(map)

    题意:单词翻译 思路:map #include<iostream> #include<stdio.h> #include<string.h> #include< ...

  7. hdu 1075 map的使用 字符串截取的常用手段 以及string getline 使用起来的注意事项

    首先说字符串的截取套路吧 用坐标一个一个的输入 用遍历的方式逐个去检查字符串中的字符是否为符合的情况 如果是的话 把该字符放入截取string 中 让后坐标前移 如果不是的话 截取结束 坐标初始化 然 ...

  8. hdu 1075 What Are You Talking About

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意:比较简单,易懂,这里不做说明. 解法:第一种方法:用map映射,耗时1000+ms:第二种 ...

  9. hdu What Are You Talking About(map)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 map简单应用 代码: #include <stdio.h> #include &l ...

随机推荐

  1. Css学习总结(2)——60个有用CSS代码片段

    1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...

  2. Bing地图切片原理

    Bing地图切片系统 Bing地图提供了一个可以直接平移和缩放的世界地图.为了让地图操作更加平滑和及时响应,我们选择提前渲染地图不同层级的细节,并把每个层级的地图切割成为瓦片以便快速的还原展示.这篇文 ...

  3. linux内核模块笔记

    主题: 1. 嵌入式基础知识 2. linux内核介绍 3. 内核的编译和安装(x86) 4. 第一个模块 5. 模块的相关工具 6. 模块的符号导出 7. 模块的參数 1.看linux/module ...

  4. Codeforces 13C Sequence dp

    题目链接:http://codeforces.com/problemset/problem/13/C 题意: 给定n长的序列 每次操作能够给每一个数++或-- 问最少须要几步操作使得序列变为非递减序列 ...

  5. activity生命周期的onPause和onStop

    搞了这么长时间的android开发,却对一些基础的东西一直模棱两可...就比方这个onPause和onStop. 假设从一个界面,跳到还有一个界面,那么是调用哪个呢? 经过我的实验.搞清楚了.onPa ...

  6. Popupwindow 显示, 其它背景变暗。 并加上点击事件 ~ (用于记录)

    public class MainActivity extends Activity implements OnClickListener { protected int mScreenWidth; ...

  7. Hadoop实战:使用Combiner提高Map/Reduce程序效率

    好不easy算法搞定了.小数据測试也得到了非常好的结果,但是扔到进群上.挂上大数据就挂了.无休止的reduce不会结束了. .. .. .... .. ... .. ================= ...

  8. [雅礼NOIP2018集训] day6

    打满暴力好像是一种挑战,已经连续几天考试最后一个小时自闭了,因为自以为打完了暴力,然而,结果往往差强人意 大概是考试的策略有些问题 T1: 我们设$g[x]$为在x时取小于等于m个物品的最大价值,下面 ...

  9. [poj 3349] Snowflake Snow Snowflakes 解题报告 (hash表)

    题目链接:http://poj.org/problem?id=3349 Description You may have heard that no two snowflakes are alike. ...

  10. Elasticsearch之下载源码

    第一步:进入github.com 第二步: 第三步: 第四步: 第五步: 第六步: 第七步:认识下es的源码目录结构