HDU 1075 What Are You Talking About (strings)
What Are You Talking About
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K (Java/Others)
Total Submission(s): 15966 Accepted Submission(s): 5177
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.
START
from fiwo
hello difh
mars riwosf
earth fnnvk
like fiiwj
END
START
difh, i'm fiwo riwosf.
i fiiwj fnnvk!
END
hello, i'm from mars.
i like earth!HintHuge input, scanf is recommended.
解析:将词典存在map中,然后对于history中的每一个词都查找能否在词典中找到,若能找到。则替换之;若没有,则直接输出。
AC代码:
#include <bits/stdc++.h>
using namespace std; map<string, string> m; int main(){
#ifdef sxk
freopen("in.txt", "r", stdin);
#endif // sxk string s, ss;
cin>>s;
while(cin>>s){
if(s == "END") break;
cin>>ss;
m[ss] = s;
}
cin>>s;
getchar();
ss = "";
while(getline(cin, s)){
if(s[0] == 'E' && s[1] == 'N' && s[2] == 'D') break;
int n = s.size();
for(int i=0; i<n; ){
while(i < n && isalpha(s[i]) && s[i] != ' ') ss += s[i ++];
if(ss == ""){ cout<<s[i ++]; continue; }
if(m.count(ss)) cout<<m[ss];
else cout<<ss;
ss = "";
}
puts("");
}
return 0;
}
HDU 1075 What Are You Talking About (strings)的更多相关文章
- 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 What Are You Talking About(map)
题意:单词翻译 思路:map #include<iostream> #include<stdio.h> #include<string.h> #include< ...
- 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 1052 Tian Ji -- The Horse Racing(贪心)(2004 Asia Regional Shanghai)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1052 Problem Description Here is a famous story in Ch ...
- HDU 1087:Super Jumping! Jumping! Jumping!(LIS)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1358 Period (kmp求循环节)(经典)
<题目链接> 题目大意: 意思是,从第1个字母到第2字母组成的字符串可由某一周期性的字串(“a”) 的两次组成,也就是aa有两个a组成: 第三行自然就是aabaab可有两个aab组成: 第 ...
- HDU 2491 Priest John's Busiest Day(贪心)(2008 Asia Regional Beijing)
Description John is the only priest in his town. October 26th is the John's busiest day in a year be ...
- HDU - 6400 多校8 Parentheses Matrix(构造)
Parentheses Matrix Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Oth ...
- hdu多校第三场 1006 (hdu6608) Fansblog Miller-Rabin素性检测
题意: 给你一个1e9-1e14的质数P,让你找出这个质数的前一个质数Q,然后计算Q!mod P 题解: 1e14的数据范围pass掉一切素数筛法,考虑Miller-Rabin算法. 米勒拉宾算法是一 ...
随机推荐
- pytorch函数之torch.normal()
Returns a Tensor of random numbers drawn from separate normal distributions who’s mean and standard ...
- RabbitMq Queue一些方法及参数
方法: 1.QueueDeclare 声明队列 public static QueueDeclareOk QueueDeclare(String queue, Boolean durable, Boo ...
- MVC layout 命名空间引用问题
虽然用MVC做了很多项目,但是都是在别人搭好的框架上实现 今天碰到一个很简单的命名空间引用问题 如图所示,Scripts和Styles 都没有引用命名空间 解决方法一: 直接使用 System.Web ...
- JAVA数据库编程(JDBC技术)-入门笔记
本菜鸟才介入Java,我现在不急着去看那些基本的语法或者一些Java里面的版本的特征或者是一些晋级的知识,因为有一点.Net的OOP编程思想,所以对于Java的这些语法以及什么的在用到的时候在去发现学 ...
- android蓝牙耳机下的语音(输入/识别)及按键监听
背景:本人负责公司android平台的app开发,最近要开发一个语音助手类的app,类似于灵犀语音助手.虫洞语音助手等.其中有两个蓝牙耳机下的语音识别问题,比较折腾人,问题描述:1.蓝牙耳机连接下捕获 ...
- 使用jstl方式替换服务器请求地址
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
- SVN使用过程中遇到的一些问题
更新svn的客户端TortoiseSVN后 ,之前使用svn管理的文件的关联图标消失了 说明:下面的解决方法及图片来自博客:装了SVN,你的关联图标变了没有? 解决办法:在同步的文件点击右键如下图 ...
- java List去重方式及效率对比
对List去重并保证添加顺序主要有三种方式: 方式一,利用HashSet不能添加重复数据的特性 由于HashSet不能保证添加顺序,所以只能作为判断条件: private static void re ...
- Git(三)Git的远程仓库
一. 添加远程库 现在我们已经在本地创建了一个Git仓库,又想让其他人来协作开发,此时就可以把本地仓库同步到远程仓库,同时还增加了本地仓库的一个备份.常用的远程仓库就是github:https://g ...
- 1195: [HNOI2006]最短母串
思路:好像以前谁问过我这题... 状个压就好啦, 把包含在其他串中的字符串删掉, 预处理除每两个字符串之间的关系, dp[ state ][ i ] 表示在state的状态下, 最后一个字符串是第i ...