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. C# 发布APP修改APP图标以及名称

    很多时候,我们用C#编程后,都要对我们的上位机生成的图标跟名字进行修改,下面我就 VS2015 怎么修改做个说明. 1.打开项目属性 2.打开应用程序的属性界面,对相应的地方进行修改就可以了 3.修改 ...

  2. java的继承中构造方法

    构造方法在创建对象的时候是被自动调用的,然后在继承中,是先调用父类的构造方法,然后在调用子类的构造方法, 当构造方法重写之后,在super中添加对应你想要调用构造方法的参数 例:父类 package ...

  3. 如何在 Linux 上安装 Nginx (源码安装)

    如何在 Linux( CentOS ) 上安装 Nginx 1.下载 nginx 链接 : https://pan.baidu.com/s/1sll0Hrf 密码 : xnem 2.安装 gcc ( ...

  4. python监控linux性能以及进程消耗的性能

    # -*- coding: utf-8 -*- """ Created on Tue Jun 10 10:20:13 2014 @author: lifeix " ...

  5. 从QQ聊天看交流的有效性

    首先让我们看一则约10分钟的QQ群聊天记录.截图例如以下.已经进行了隐私保护. 交流的主体为大二的在校生与刚刚毕业的学长之间的对话,学长參加过培训,在校学弟想了解一下.故有了以下的交流.(从上到下,从 ...

  6. cocos2d_x_03_经常使用类的使用_事件_画图

    一.TextFieldTTF输入框的使用 #pragma mark - 自己定义方法 // 自己定义方法,加入一个 TextField void TextFieldScene::addOneTextF ...

  7. windows编译ffmpeg出现gcc is unable to create an executable file 的普通情况

    近期有个朋友在编译ffmpeg的时候出现这个问题,他非常郁闷. 我就说,为什么我弄的时候就没问题呢??直接./configure +加上后面的參数 安全度过. 然后,我就想了,预计他的gcc的系统变量 ...

  8. SSH公钥认证

    一.实验的目的 了解密钥对的创建和使用,掌握免password远程登录和远程操作 二.实验环境 本地主机 rh1: 192.168.233.3/24 远程主机 rh2: 192.168.233.4/2 ...

  9. bzoj2464: 中山市选[2009]小明的游戏(最短路)

    2464: 中山市选[2009]小明的游戏 题目:传送门 题解: 最短路的裸题... 代码: #include<cstdio> #include<cstring> #inclu ...

  10. MYSQL INT(N)以及zerofill的使用区别

    MYSQL中,int(n)括号里面的数据n无论写成多少,都是占4个字节的空间,最多能够存10位数.N不代表能够存多少位数,显示宽度M与数据所占用空间,数值的范围无关. 如果在定义字段的时候指定zero ...