前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HDUOJ---What Are You Talking About

HDUOJ---What Are You Talking About

作者头像
Gxjun
发布2018-03-21 13:19:39
7670
发布2018-03-21 13:19:39
举报
文章被收录于专栏:ml

What Are You Talking About

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

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

  map 容器的应用....map[aa]=bb;

  STL;

代码:

代码语言:javascript
复制
 1 #pragma warning (disable:4786)
 2 #include<iostream>
 3 #include<map>
 4 #include<string>
 5 #include<cstdio>
 6 #include<cstring>
 7 #include<cstdlib>
 8 using namespace std;
 9 const int maxn =3002;
10 char aa[maxn+1],bb[15];
11 int main()
12 {
13     scanf("%*s");
14     map<string,string>msg;
15     while(scanf("%s",aa),strcmp(aa,"END"))
16     {
17       scanf("%s",bb);
18         msg[bb]=aa;
19     }
20       scanf("%*s");
21       getchar();
22       map<string,string>::iterator it;
23       memset(bb,'\0',sizeof(bb));
24       while(cin.getline(aa,3002),strcmp(aa,"END"))
25       {
26           int step=0;
27           for(int i=0;i<strlen(aa);i++)
28           {
29             if((aa[i]<'a'||aa[i]>'z'))
30             {
31              if(step)
32              {
33                 it=msg.find(bb);
34                 if(it!=msg.end())
35                 {
36                   cout<<(*it).second;
37                 }
38                 else
39                     printf("%s",bb);
40                 step=0;
41                 memset(bb,'\0',sizeof(bb));
42              }
43                 cout<<aa[i];
44             }
45             else
46             {
47               bb[step++]=aa[i];
48             }
49           }
50           puts("");
51       }
52     return 0;
53 }
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2013-10-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • What Are You Talking About
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档