hdu 1075 What Are You Talking About (map)

What Are You Talking About
Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others)
Total Submission(s): 28601    Accepted Submission(s): 9743

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!
 

 

C/C++:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <iostream>
 4 #include <map>
 5 using namespace std;
 6 const int MAX = 20;
 7 
 8 char buf[MAX], s1[MAX], s2[MAX], ch;
 9 int pos = 0;
10 
11 map <string, string> m;
12 
13 int main()
14 {
15     gets(buf);
16     while (scanf("%s%s", &s1, &s2), strcmp(s1, "END"))
17     {
18 //      scanf("%s", &s2);
19         m[s2] = s1;
20     }
21     getchar();
22     while (scanf("%c", &ch))
23     {
24         if (isalpha(ch)) buf[pos ++] = ch;
25         else
26         {
27             buf[pos] = '\0', pos = 0;
28             if (strcmp(buf, "END") == 0) break;
29             if (m.find(buf) != m.end())
30                 cout <<m[buf];
31             else
32                 printf("%s", buf);
33             printf("%c", ch);
34         }
35     }
36     return 0;
37 }

 

转载于:https://www.cnblogs.com/GetcharZp/p/9547363.html

基于Cesium移动的天空云 天空中的云朵也算是一种天气气候的效果,它能更加逼真的反映当前的天气状况,可以是白云朵朵,也可以是乌云密布,结合其他天气效果,可以组合形成较为真实的三维可视化场景。 阅读详情

相关推荐

RTL优化与PPA分析:数字电路设计的关键技术

在数字集成电路设计中,RTL(寄存器传输级)优化是提升芯片性能、降低功耗和减小面积的核心技术。通过PPA(Power-Performance-Area)指标的平衡,工程师可以在不同时序约束下实现设计的最优化。本文基于Synopsys Design Compiler和开源工具Yosys的实验数据,展示了RTL优化在算术单元和控制逻辑中的显著效果,特别是在乘法器和除法器等复杂运算模块中。文章还探讨了AI辅助工具在RTL优化中的应用潜力,为数字电路设计提供了实用的技术参考和工程实践建议。

weixin_42186387的博客 619

Maps-STL

内容:说明:示例代码:// Maps_STL.cpp: 定义控制台应用程序的入口点。 // #include "stdafx.h" #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;map&gt; using namespace std; //by zhaocl int main() { int n; ...

半雨微凉 389

[OHIF-Viewers]医疗数字阅片-医学影像-cornerstone-core-Cornerstone.js-Cornerstone Examples-基石实例-下...

[OHIF-Viewers]医疗数字阅片-医学影像-cornerstone-core-Cornerstone.js-Cornerstone Examples-基石实例-下 CT Image with Window presets This is an example of displaying a ct image along with buttons to set ww/wc pres...

浩秦的博客 1841

杭电 1075 What Are You Talking About

Problem DescriptionIgnatius 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 En

hym666的专栏 1914

Windows版本Carla(含RoadRunner插件)源码安装+RoadRunner地图导入

通过跳转浏览器账号密码登录github,不要选择Fine-grained personal access tokens,在git clone时会显示非授权,也不要使用Windows凭据!核心指令:编译PythonAPI–make PythonAPI,,编译Server–make launch,封装”游戏“–make package。完成安装后,在已安装->2022版本右侧->更多->导入配置,选择配置文件(需将配置文件内容更新为手册内容,如下图)->详细信息,更新。不要修改版本,执行上面指令即可!

winnizap的博客 1467

ldpc编解码器设计与仿真

计算校验节点到变量节点的消息 m_{c \to v}=2 \cdot atanh(\prod_{v’ \in N©\setminus v}tanh(\frac{m_{v’ \to c}}{2}))。计算变量节点到校验节点的消息 m_{v \to c}=L_{v,0}+\sum_{c’ \in M(v)\setminus c}m_{c’ \to v}。◦ 对于每个变量节点 v,计算最终 LLR 值 L_{v,f}=L_{v,0}+\sum_{c \in M(v)}m_{c \to v}。

youngerwang的博客 809

string 容器使用时需要注意......

1.题目引入: 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. Ca

weixin_52914088的博客 204

Halcon手眼标定保姆级教程:从‘眼在手上’到‘眼到手’两种模式全解析(附代码)

本文详细解析Halcon在机器人视觉引导中的手眼标定技术,涵盖Eye-in-Hand和Eye-to-Hand两种模式,提供从硬件准备到实战代码的完整解决方案。通过精确的相机标定和坐标转换,帮助实现工业自动化中机械臂与视觉系统的高精度协同作业。

weixin_42544461的博客 209

NumPy代码零修改GPU加速:TensorFlow实验性API实战指南

NumPy作为Python科学计算基石,天然受限于CPU算力瓶颈;其核心原理依赖内存连续访问与SIMD指令优化,难以直接利用GPU的并行计算能力。通过TensorFlow的tf.experimental.numpy等实验性API,可在不重构原有逻辑的前提下,实现矩阵乘法、SVD、FFT等密集计算的GPU卸载,技术价值在于兼顾兼容性与性能——既复用成熟SciPy/Pandas生态,又获得10倍级加速。典型应用场景包括气候模型参数扫描、基因表达矩阵分解、蒙特卡洛模拟等中大规模数值任务。本文聚焦于NumPy到GP

weixin_30765577的博客 462

AI Agent智能体在Android开发中的应用

本文探讨了AIAgent(智能代理体)在Android开发中的应用,涵盖技术原理、实践案例与未来趋势。AIAgent通过机器学习、自然语言处理等技术实现代码生成、测试自动化及性能优化,显著提升开发效率。例如,强化学习模型可优化APP响应时间(公式:$\text{响应时间}=f(\text{负载},\text{资源})$),自动化测试覆盖率提升至95%。

郑伟强dev的专栏 124

视频理解与处理——OpenClaw视频能力深度解析(2026视频版)

本文介绍了OpenClaw视频理解与处理的核心技术,重点分析了视频预处理流程。通过VideoProcessor类实现视频加载、帧采样、尺寸调整和归一化等基础处理功能,支持本地和在线视频源处理,为后续视频分析任务提供标准化输入。预处理模块采用均匀采样和标准化方法优化视频数据,确保动作识别、场景分析等高级应用的准确性,展现了OpenClaw强大的视频处理能力。

一键难忘的博客 464

What Are You Talking About(字典树)

题意:给火星文对应的翻译,然后输入一篇文章把对应能翻译的单词翻译过来,不能翻译的原样输出。 思路:其实这道题可以用map很简单做出来,但是用map时间复杂度很高,字典树只有几百毫秒才是标准写法。 首先建立一颗字典树,在单词的最后一个地方把对应的单词解释放进去,不是一个完整单词结束的地方就随便赋值一个用不到的符号。然后就是处理文章有点麻烦。如果是字母就存到一个临时字符串里面,一旦遇到空格,标点等...

MikeJackSTG的博客 708

案例:无人船测量点位数据+ArcGIS 10.6软件生成三维水下地形的两种方法

通常情况下,采用无人船进行水下地形测量,得到的是离散的,具有点号、日期、时间、东坐标(E)、北坐标(N)、水面高程、水下高程和水深等信息的点位数据,该数据一般由航带点位数据加水岸线组成,如下图所示: 原始点位数据格式如下: 下面讲解在ArcGIS软件中生成三维水下地形的两种常用方法。 一、构建不规则三角网(Tin) 1、创建Tin 生成的Tin: 2、Tin转栅格 Tin to Raster: 三维展示: 二、空间插值 栅格插值常用的方法有:克里...

智慧空间实验室 6750

hdu1075 What Are You Talking About map映射

What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others)Total Submission(s): 26458    Accepted Submission(s): 9036Problem DescriptionIgnatius is...

popcjz的博客 1623

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

HDU 1075 What Are You Talking About (map解法+Trie解法)

HDU 1075 What Are You Talking About (map解法+Trie解法) ACM 题目地址:  HDU 1075 What Are You Talking About 题意:  给出一个“翻译-原文”的对应表,然后给出句子,要把句子中的原文都翻译出来。 分析:  可以用map赤裸裸地做,但是比较花费时间,虽然这题时间给了5s,map解法是能

水果君の日常 5066

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

hdu1075What Are You Talking About(map容器)

题目地址 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): 175

ACMan 665

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

HDU - 1075 What Are You Talking About 字符串转换 map

HDU - 1075 What Are You Talking About 题意: 给你一些英文对应的火星文,将输入的火星文句子转换为英文。(标点符号和未给出的转换单词原样输出) #include<iostream> #include<cstdio> #include<cstring> #include<set> #include&lt...

没有梦想何以远行 223

【STL_map / 字典树】HDU 1075 What Are You Talking About

PE了一发,因为gets会读回车!!!!

L_X_ 232

【HDU 1075 --- What Are You Talking About】map

【HDU 1075 --- What Are You Talking About】map 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...

来日浅谈的博客 391

HDU 1075 What Are You Talking About 【map的应用】

What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others)Total Submission(s): 26656    Accepted Submission(s): 9126Problem Description Ignatius i...

Emiya丶的博客 242

hdu 1075 What Are You Talking About 字典树 或 stl map

伐我爱你

myHelperIsMe的专栏 887

HDU1075 What Are You Talking About——字典树、map

点这里 题意: 在START 和END 之间给出一个替换列表,每行有两个单词a和b。之后又在START 和END 给出几句话,要求把每句话中,在替换列表出现过的b,都替换成a。 题解: 一个字符串替换成另一个字符串,用map来做是最简单的。同时为了复习字典树,也用字典树做了一遍。 过程中犯的错: 每句话中取单词。后续代码中呈现的是我能想到的最简便的方法,一开始为了这个弄得非常复杂。 字典树中的search 函数。我特意改成了返回string类型,方便我直接输出。但是有一种情况,比如我替换列表中出现了单

lllllan 182

(map)What Are You Talking About hdu1075

What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 102400/204800 K (Java/Others) Total Submission(s): 25683Accepted Submission(s): 8745 Problem Descr...

140

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 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 E

蒟蒻本蒻的博客 216

HDU1075_What Are You Talking About_stl的map

What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others) Total Submission(s): 21658    Accepted Submission(s): 7228 Problem Descriptio

弱的奋斗之旅 373

What Are You Talking About HDU - 1075(使用map来做)

map 是STL中的关联容器,map中的元素由&amp;lt;key, value&amp;gt;对构成,而且key和value的数值类型可以是任意类型。使用map要包含头文件 map 标题map的声明 map&amp;lt;string,string&amp;gt; dict; //第一种 typedef map&amp;lt;string,string&amp;gt; MAP; //第二种 MAP dict; 标

上帝是个娘们的博客 237
上一篇: hdu 1263 水果 (嵌套 map)
下一篇: nyoj 991-Registration system (map)
devon2014
博客等级 码龄12年 3粉丝 144原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值