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算法. 米勒拉宾算法是一 ...
随机推荐
- oracle列转行
unpivot()函数需要Oracle版本大于等于11g --创建表 create table Fruit(id int,name varchar(20), Q1 int, Q2 int, Q3 in ...
- Project Euler Problem4
Largest palindrome product Problem 4 A palindromic number reads the same both ways. The largest pali ...
- makefile 中 foreach
四.foreach 函数 foreach函数和别的函数非常的不一样.因为这个函数是用来做循环用的,Makefile中的foreach函数几乎是仿照于Unix标准Shell(/bin/sh)中的for语 ...
- apache+php windows下配置
2014年1月9日 13:58:54 现在PHP大部分是vc9编译的,其扩展在windows下大部分也都是用vc9编译的(memcache,xdebuge...),,所以要想Apache+PHP+PH ...
- Jmeter遇到Connection reset by peer的解决方法
解决方案如下: 1.修改HTTP请求下面的Impementation选项,改成HttpClient4 2.修改了/bin/jmeter.bat文件:找到这2行 set HEAP=-Xms256m -X ...
- PHPStorm 配置本地服务器
本篇教程为配置 PHPStorm 本地服务器,以方便程序调试. 本地服务器工具:XAMPP for windows 7.1.1-0 / Apache 2.4.25 ( Win32 ) / PHP 7. ...
- Java 组合
组合: 在新类中产生现有类的对象,由于新的类是由现有类的对象所组成,所以这种方法称为组合 组合和继承都允许在新的类中放置对象,组合时显示的这样做,而继承则是隐式的这样做 组合技术通常用于想在新类中使用 ...
- 2018-2019-2 网络对抗技术 20165301 Exp1 PC平台逆向破解
任务一 直接修改程序机器指令,改变程序执行流程 1.输入指令objdump -d pwn5301 | more反汇编pwn1文件. 通过反汇编,可以看到main函数中的call 804891,其机器码 ...
- react 的JSX语法需要注意哪些点?
注释方式 ReactDOM.render( <div> {/*JSX 中的注释方式*/} </div>, document.getElementById('root') ) j ...
- Ruby语言学习笔记
在codecademy上开始玩ruby了 1.数据类型:boolean,string,number 变量直接用即可,不用声明(“拿来主义”) 运算符:+ - * / ** % == != && ...