http://acm.hdu.edu.cn/showproblem.php?pid=1075

What Are You Talking About

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

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!

题目大意:给你一些字符串和对应的字符串,然后给出一些话,然后根据之前的字符串来对应输出,如果没有对应,则输出原来的字符串。

代码:

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <map>
using namespace std; #define MAX 0x7fffffff
#define N 3000 map<string,string> m;
map<string,string>::iterator it; int main(){
//freopen("D:\\input.in","r",stdin);
//freopen("D:\\output.out","w",stdout);
char s1[N],s2[N];
gets(s1);
while(){
scanf("%s",s1);
if(s1[]=='E'){
break;
}else{
scanf("%s",s2);
m.insert(pair<string,string>(string(s2),string(s1)));
}
}
gets(s1);
gets(s1);
while(){
gets(s1);
if(s1[]=='E'){
break;
}else{
int len=strlen(s1),step=;
for(int i=;i<len;i++){
if(s1[i]>='a'&&s2[i]<='z'){
s2[step++]=s1[i];
continue;
}else{
s2[step]='\0';
it=m.find(string(s2));
if(it!=m.end()){
printf("%s",(*it).second.c_str());
}else{
printf("%s",s2);
}
step=;
putchar(s1[i]);
}
}
puts("");
}
}
return ;
}

hdoj1075-What Are You Talking About 【map】的更多相关文章

  1. 【第40套模拟题】【noip2011_mayan】解题报告【map】【数论】【dfs】

    目录:1.潜伏者 [map] 2.Hankson的趣味题[数论]3.mayan游戏[dfs] 题目: 1. 潜伏者(spy.pas/c/cpp)[问题描述]R 国和S 国正陷入战火之中,双方都互派间谍 ...

  2. 01 语言基础+高级:1-6 集合_day04【Map】

    day04 [Map] 主要内容 Map集合 教学目标 能够说出Map集合特点 使用Map集合添加方法保存数据 使用”键找值”的方式遍历Map集合 使用”键值对”的方式遍历Map集合 能够使用Hash ...

  3. 【Map】MapTest

    package cn.itcast.p1.map.test; import java.util.HashMap; import java.util.Map; public class MapTest2 ...

  4. 【Map】获取字符串中,每一个字母出现的次数

    package cn.itcast.p1.map.test; import java.util.Iterator; import java.util.Map; import java.util.Tre ...

  5. HDU 4941 Magical Forest 【离散化】【map】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4941 题目大意:给你10^5个点.每一个点有一个数值.点的xy坐标是0~10^9.点存在于矩阵中.然后 ...

  6. [CF Round #294 div2] D. A and B and Interesting Substrings 【Map】

    题目链接:D. A and B and Interesting Substrings 题目大意 给定26个小写字母的权值,一共26个整数(有正有负). 给定一个小写字母组成的字符串(长度10^5),求 ...

  7. 【Map】Double Queue

    Double Queue Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13258   Accepted: 5974 Des ...

  8. 【map】p1184 高手之在一起

    题目背景 高手是可以复活的,这点我们大家都知道. 题目描述 高手列出了一个详尽的日程表,这次他要追求的则是一个心灵纯洁的小萝莉.他和她都是要上课的,但是也会有时间空闲,于是高手决定无时无刻都要跟着她. ...

  9. UVa-156 Ananagrams 反片语【map】【vector】

    题目链接:https://vjudge.net/contest/211547#problem/D 题目大意: 输入一些单词,找出所有满足以下条件的单词:该单词不能通过字母重排,得到输入文本中的另外一些 ...

  10. 洛谷 P1571 眼红的Medusa【二分查找】 || 【map】

    题目链接:https://www.luogu.org/problemnew/show/P1571 题目描述 虽然Miss Medusa到了北京,领了科技创新奖,但是他还是觉得不满意.原因是,他发现很多 ...

随机推荐

  1. windows git 清除已保存的密码

    进入git目录 右键 git-bash.exe 执行命令: git config --system --unset credential.helper 然后执行git clone http://... ...

  2. jquery ztree异步搜索

    一.初始异步加载树 初始化默认给出一个根结点,再结合异步加载的方式手动触发默认加载第一层,如图: 代码如下: var treeSetting = { async: { enable: true, ur ...

  3. Oracle 统计量NO_INVALIDATE参数配置(下)

    转载:http://blog.itpub.net/17203031/viewspace-1067620/ 本篇我们继续讨论NO_INVALIDATE参数. 从上篇(http://blog.itpub. ...

  4. bootstrap 教程分享

    Bootstrap 教程 Bootstrap 简介 Bootstrap 环境安装 Bootstrap CSS 概览 Bootstrap 网格系统 Bootstrap 排版 Bootstrap 代码 B ...

  5. Supervisor: 进程控制系统

    Supervisor: 进程控制系统 概述:Supervisor是一个 Client/Server模式的系统,允许用户在类unix操作系统上监视和控制多个进程,或者可以说是多个程序. 它与launch ...

  6. Servlet、Servlet容器等内容讲解

    转载自http://blog.csdn.net/iAm333 对于Servlet.Servlet容器以及一个Servlet容器-Tomcat这些概念讲解的挺清晰的,转载下 之前在开源中国看到一篇文章& ...

  7. Nginx相关笔记

    相关参考: 编译安装测试nginx            https://www.cnblogs.com/jimisun/p/8057156.html

  8. leetcode412

    public class Solution { public IList<string> FizzBuzz(int n) { var list = new List<string&g ...

  9. Socket Error # 10013 Access denied

    --------------------------- Debugger Exception Notification --------------------------- Project xxx. ...

  10. xe fmx 怎么改变button颜色

    xe fmx 怎么改变button颜色 改变照相机的默认像素CameraComponent1