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. [terry笔记]GoldenGate_迁移同步_主库零停机

    ogg根据scn同步数据,源库零停机时间 本次实验与上次的区别:更加注重细节,几乎包含所有步骤,把我越到的坑都作出了说明.并且同步是由10g向11g进行同步,更加符合升级迁移需求. 如下是主要步骤: ...

  2. 高级函数-sign

    ==========sign函数介绍(补充)===========   sign(n):判断n>0返回1;n=0返回0;n<0返回-1.   select sign(10),sign(0) ...

  3. oauth2.0里回调地址返回code中如何让code不显示在URL里?

    背景: 最近在调用对方提供的oauth2.0接口的时候,返回code在URL显示,但是会影响到本系统调用其他的菜单项的操作,所以想把返回的code值去掉. 解决办法:     想了各种解决办法,目前把 ...

  4. 确保 Xcode 每次 Build 时都自己主动更新资源

    參考:p=22" target="_blank">http://quick.cocoachina.com/?p=22 刚建立的quickproject.每次修改lu ...

  5. 个人andriod实习小作品,个人联网笔记本

    个人联网笔记本 个人信息:就读于燕大本科软件project专业 眼下大四; 本人博客:google搜索"cqs_2012"就可以; 个人爱好:酷爱数据结构和算法,希望将来从事算法工 ...

  6. QMutex“A mutex must be unlocked in the same thread that locked it”解决(在run里创建对象是不二法宝)

    多线程时出现如下警告信息: A mutex must be unlocked in the same thread that locked it: 原因可能有二: 1.创建QMutex不在当前线程: ...

  7. [Codeforces 911F] Tree Destruction 解题报告(贪心)

    题目链接: http://codeforces.com/contest/911/problem/F 题目大意: 给你一棵树,每次挑选这棵树的两个度数为1的点,加上他们之间的边数(距离),然后将其中一个 ...

  8. [转帖]关于Xilinx下Micro_Blaze中UartLite232外设的使用

    来源:https://blog.csdn.net/shen_you/article/details/78713746

  9. 3dmax实例教程-使用3ds Max 创建一个完整的场景

    本篇教程讲述了利用3ds max创建一个完整的场景. 灵感来源:当我在遇到一些事情睡不着觉的时候我便在努力想象一些别的事情,于是我便想到了这个场景,其实对于我的这个角色我即没有参考图也没有草稿图,有的 ...

  10. LightOJ-1259 Goldbach`s Conjecture 数论 素数筛

    题目链接:https://cn.vjudge.net/problem/LightOJ-1259 题意 给一个整数n,问有多少对素数a和b,使得a+b=n 思路 素数筛 埃氏筛O(nloglogn),这 ...