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): 16042 Accepted Submission(s): 5198
into English. Can you help him?
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.
from fiwo
hello difh
mars riwosf
earth fnnvk
like fiiwj
END
START
difh, i'm fiwo riwosf.
i fiiwj fnnvk!
END
i like earth!
Huge input, scanf is recommended.
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)的更多相关文章
- 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 ...
- hdu 1075 (map)
http://acm.hdu.edu.cn/showproblem.php?pid=1075 What Are You Talking About Time Limit: 10000/5000 MS ...
- 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 ...
- 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 ...
- HDU 1075 字符串映射(map)
Sample InputSTARTfrom fiwohello difhmars riwosfearth fnnvklike fiiwjENDSTARTdifh, i'm fiwo riwosf.i ...
- hdu 1075 What Are You Talking About(map)
题意:单词翻译 思路:map #include<iostream> #include<stdio.h> #include<string.h> #include< ...
- hdu 1075 map的使用 字符串截取的常用手段 以及string getline 使用起来的注意事项
首先说字符串的截取套路吧 用坐标一个一个的输入 用遍历的方式逐个去检查字符串中的字符是否为符合的情况 如果是的话 把该字符放入截取string 中 让后坐标前移 如果不是的话 截取结束 坐标初始化 然 ...
- hdu 1075 What Are You Talking About
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意:比较简单,易懂,这里不做说明. 解法:第一种方法:用map映射,耗时1000+ms:第二种 ...
- hdu What Are You Talking About(map)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 map简单应用 代码: #include <stdio.h> #include &l ...
随机推荐
- C#-C#6.0新特性
来自为知笔记(Wiz)
- oracle存储过程中使用execute immediate执行sql报ora-01031权限不足的问题
oracle存储过程中使用execute immediate执行sql报ora-01031权限不足的问题 学习了:http://blog.csdn.net/royzhang7/article/deta ...
- 数据挖掘算法学习(四)PCA算法
转载请附上链接http://blog.csdn.net/iemyxie/article/details/38236647 算法简单介绍 主成分分析(PrincipalComponentAnalysis ...
- RedHat6.5 安装OpenStack all in one-RDO方式
OpenStack是一个开源的云平台.由各个组件协同工作,安装非常复杂. RedHat有个关于Openstack的项目RDO,能够简化安装过程,可是假设真按RDO所说的三步去安装,发现安装过程中还是有 ...
- MongoDB(一)——简介
这两天简单学习了一下MongoDB数据库,属于NoSQL类型数据库的一种,先简单宏观的看一下NoSQL的相关知识和MongoDB的基础知识. NoSQL是Not Only SQL的缩写,它指的是非关系 ...
- 归并排序(Python)
一.采用分治策略:将原问题划分成n个规模较小的但结构和原问题相同的子问题,递归解决这些子问题后合并各个结果从而得到原问题的解. 二.分治策略的步骤: 分解:将原问题分解成一系列子问题 解决:子问题粒度 ...
- win10+ubuntu双系统卸载ubuntu
进入win10下载EasyUEFI,删除ubuntu的引导项.重启如果直接进入了win10,表示卸载成功了.然后可以格式化ubuntu的分区.
- iOS开发—在@interface,@implementation和@property中变量的定义
一直搞不懂在OC中变量在@interface和@implementation中有什么区别,定义@property又有什么不同,查了很多资料,总结如下: //ViewController.h @inte ...
- CentOS7安装第三方yum源EPEL
转自:https://blog.csdn.net/u012208775/article/details/78784616 一.简介 EPEL是企业版 Linux 附加软件包的简称,EPEL是一个由Fe ...
- VBA 第一天
公司实习第一天,excel搞不定啊,学点VBA留着用: 录制宏: 点击录制宏按钮以后,在这段期间你做的每一个操作都会被记录下来,直到你点击停止录制按钮才能够停下,停下来后在此期间每一个操作都会以宏代码 ...