二分贪心 B
来源:互联网 发布:流量互刷软件 编辑:程序博客网 时间:2024/06/16 21:09
题目:
You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.
Input
Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output
Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".
Sample Input
dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay
Sample Output
catehloops
Hint
Huge input and output,scanf and printf are recommended.
分析:
将不同的语言存放到map容器中,在对要查找的的语言进行查找,输出其对应的语言即可。
代码:
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
multimap<string,string>v;
multimap<string,string>::iteratorit;
string s1,s2;
char s[100],m[100],n[100];
while(gets(s))
{
if(!strlen(s))break;
sscanf(s,"%s %s",m,n);
s1=m;
s2=n;
v.insert(make_pair(s2,s1));
}
while(cin>>s1)
{
it=v.find(s1);
if(it!=v.end())
cout<<(*it).second<<endl;
else
cout<<"eh"<<endl;
}
}
#include<algorithm>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
multimap<string,string>v;
multimap<string,string>::iteratorit;
string s1,s2;
char s[100],m[100],n[100];
while(gets(s))
{
if(!strlen(s))break;
sscanf(s,"%s %s",m,n);
s1=m;
s2=n;
v.insert(make_pair(s2,s1));
}
while(cin>>s1)
{
it=v.find(s1);
if(it!=v.end())
cout<<(*it).second<<endl;
else
cout<<"eh"<<endl;
}
}
0 0
- 二分贪心专题B
- 二分贪心 B
- 二分贪心 B 字典
- 二分贪心 B
- 二分贪心 B题
- 二分贪心—B
- 二分贪心-B
- 二分贪心-B
- CodeForces 287B 二分贪心
- cf 484B 二分+贪心
- ACM-二分贪心B-02
- 二分贪心——B
- !CodeForces 287B--(贪心、二分)
- B. Preparing for the Contest----二分+贪心
- CF 329B(Biridian Forest-贪心-非二分)
- CodeForces 377B---Preparing for the Contest(二分+贪心)
- Codeforces Round #334 B. More Cowbell (二分 + 贪心)
- CodeForces 377B-Preparing for the Contest(二分+贪心)
- 使用JAVA Get POST 抓网页的练习代码
- 类
- 如何避免javascript中的冲突
- Gem Port和T-CONT实现业务复用
- 欢迎使用CSDN-markdown编辑器
- 二分贪心 B
- Web前端开发面试题——将字符串转成驼峰写法
- [UE4]方法标签(总结)
- cocos Creator计时器schedule的使用和坑
- HTML5 FileReader分布读取文件以及其方法简介
- android技术之SQLite技术详解
- 关于异常那些事
- Opencv Mat矩阵点乘
- 前端工程师技能之photoshop巧用系列第三篇——切图篇