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. OO第一单元总结__多项式求导问题

    作业一.含幂函数的简单多项式的求导 (1)基于度量的程序结构分析 1. 统计信息图: 2. 结构信息图: 3. 复杂度分析 基本复杂度(Essential Complexity (ev(G)).模块设 ...

  2. java源码之Comparable和Comparator

    1,Comparable 简介 Comparable 是排序接口. 若一个类实现了Comparable接口,就意味着“该类支持排序”.  即然实现Comparable接口的类支持排序,假设现在存在“实 ...

  3. SQLSERVER-存储过程知识点

    原文链接:http://www.qeefee.com/article/000566 存储过程是一组预编译的SQL语句,它可以包含数据操纵语句.变量.逻辑控制语句等. 存储过程允许带参数: 输入参数:可 ...

  4. Tarjan缩点【模板】

    #include <algorithm> #include <cstdio> #include <map> using namespace std; ); map& ...

  5. HDU 4339 Contest 4

    树状数组,主要是抓住要求连续1的个数.这样,初始时,相同的加1,不同的加0. 查询时,用二分搜索右边界.就是比较当前mid-l+1的值与他们之间1的个数(这可以通过树状数组求区间和得出),记录右边界即 ...

  6. adt-bundle-windows加入NDK支持

    近期换了个硬盘,曾经都是用eclipse安装adt插件的,如今老了,图省事就下载了adt-bundle-windows,解压缩出来就直接用.但是这个adt-bundle没有集成NDK支持,于是手动安装 ...

  7. ubuntu16.04环境下安装配置openface人脸识别程序

    参考http://blog.csdn.net/weixinhum/article/details/77046873 最近项目需要用到人脸训练和检测的东西,选用了OpenFace进行,因而有此文. 本人 ...

  8. poj_1952最大下降子序列,统计个数

    其实不算难的一道题,但憋了我好久,嗯,很爽. #include<iostream> #include<cstdio> #include<string.h> #inc ...

  9. zzulioj--1716--毒(模拟水题)

     1716: 毒 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 96  Solved: 43 SubmitStatusWeb Board Desc ...

  10. Oracle GoldenGate

    Oracle GoldenGate实现数据库同步 前言:最近刚好在弄数据库同步,网上查了些资料再加上自己整理了一些,做个分享! 一.GoldenGate的安装 官方文档: Oracle®GoldenG ...