杭电1075 ╰+攻爆jí腚メ 2022-06-04 08:06 113阅读 0赞 # What Are You Talking About # **Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K (Java/Others) Total Submission(s): 7555 Accepted Submission(s): 2341** 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. //1075 #include <iostream> #include <fstream> #include <string> #include <map> using namespace std; int main() { //ifstream cin("in.txt"); string temp; string temp1; map<string, string> dic; if (cin >> temp && strcmp(temp.c_str(), "START") == 0) { while (cin >> temp && strcmp(temp.c_str(),"END")!=0) { cin >> temp1; dic[temp1] = temp; } cin >> temp; cin.get(); if(strcmp(temp.c_str(),"START") == 0) { while(1) { getline(cin,temp); if (strcmp(temp.c_str(), "END") == 0) break; int i = 0; while(i < temp.size()) { temp1 = ""; while (i < temp.size()&&(temp[i] >= 'a' && temp[i] <= 'z' )) { temp1.insert(temp1.end(),temp[i]); i = i + 1; } if (dic.find(temp1) != dic.end()) cout << dic[temp1]; else cout <<temp1; while ( i < temp.size()&&(temp[i] < 'a' || temp[i] > 'z')) { cout <<temp[i]; i = i + 1; } } cout << endl; } } } //cin.close(); return 0; }
相关 杭电1061 Rightmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J 布满荆棘的人生/ 2022年09月17日 05:27/ 0 赞/ 262 阅读
相关 杭电1039 Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6553 一时失言乱红尘/ 2022年06月05日 12:48/ 0 赞/ 269 阅读
相关 杭电1075 What Are You Talking About Time Limit: 10000/5000 MS (Java/Others) Memory L ╰+攻爆jí腚メ/ 2022年06月04日 08:06/ 0 赞/ 114 阅读
相关 杭电1026 Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6553 快来打我*/ 2022年06月04日 05:53/ 0 赞/ 288 阅读
相关 杭电oj Problem Title 2 Pro. ID 1001 Sum Problem include<stdio.h> int main() { 缺乏、安全感/ 2022年05月15日 16:18/ 0 赞/ 251 阅读
相关 杭电oj Problem Title 1 Pro. ID 1000 A+B Problem include<stdio.h> int main() { £神魔★判官ぃ/ 2022年05月15日 16:14/ 0 赞/ 319 阅读
相关 杭电1060 此题是一道数学题,也是一道技巧题,也是不能直接算的,否则会超时的!!! 此题思路: 设n^n=d.xxxx\10^(k-1),其中k表示n^n的位数; d.xxxx 痛定思痛。/ 2021年12月01日 22:40/ 0 赞/ 306 阅读
相关 杭电2075 此题真的是简单的再不能简单了!呵呵!我一直纠结,出这样的题是什么意思呢?不懂!哎,不说那些废话了,直接 ac吧!呵呵! \include<iostream> using 今天药忘吃喽~/ 2021年12月01日 22:38/ 0 赞/ 288 阅读
相关 杭电2078 说实话,此题是一道有严重bug的问题,对于xhd没晚能复习的科目数m根本就没用上!!!哎不管那么些了,反正ac了!呵呵!此题这样想xhd得复习效率是前一课程和后一课程复习效率差 ╰+攻爆jí腚メ/ 2021年12月01日 22:38/ 0 赞/ 339 阅读
相关 杭电2090 此题就是一道令人无法琢磨的题!哎!!我简直就无语了!!呵呵!竟然能出这题。。。。 废话少说,直接ac!!! \\\ 此题要想输出结果,还需要注意一下! 在linux 约定不等于承诺〃/ 2021年12月01日 21:12/ 0 赞/ 349 阅读
还没有评论,来说两句吧...