Problem J: STL——字典
来源:互联网 发布:淘宝常用的花肥有哪些 编辑:程序博客网 时间:2024/05/17 06:12
Description
输入n个字符串对(str1,str2),再输入k个查询字符串str,从字符串对中查找查询字符串,即如果str=str2,则输出str1,如果查询不到则输出"eh"(不包含引号)。输入保证所有字符串对的str2不相同,字符串只含有字母和数字,长度小于20!
Input
输入包含多组数据,直到文件结尾。
每组数据第一行包含一个整数n(0≤n≤10^5)。接下来n行,每行描述一个字符串对。
接下来包含一个整数m(0≤m≤10^5)。接下来m行,每行描述一个查询字符串。
见样例
Output
输出每个查询的结果。
Sample Input
5
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
3
atcay
ittenkay
oopslay
Sample Output
cat
eh
loops
HINT
用STL的map容易实现
#include<map>#include<string>#include<iostream>using namespace std;int main(){ ios::sync_with_stdio(false); int i,n; string w,p; map<string,string> d; while(cin>>n){ d.clear(); while(n--){ cin>>w;cin>>p;d[p]=w; } cin>>n; while(n--){ string tmp; cin>>tmp; if(d.count(tmp)!=0) cout<<d[tmp]<<endl; else cout<<"eh"<<endl; } } return 0;}
0 0
- Problem J: STL——字典
- Problem J: STL——字典
- Problem : STL——字典
- 贪心算法—problem j
- 动态规划—Problem J
- 图算法—Problem J
- 动态规划——problem j】
- oj刷题—Problem J: 螺旋方阵
- Problem : STL——水果店
- Problem J. Worried School(日期模拟 STL)
- Problem J
- Problem J
- Problem J
- Problem-J
- Problem J
- Problem-J
- Problem J
- problem j
- HDOJ6019 MG loves gold 题解
- mxnet的更新问题
- 第五届蓝桥杯JavaB组第7题
- 海量数据处理
- 24点游戏
- Problem J: STL——字典
- JAVA基础知识整理(十) ---算法
- CSS中id和class的引用
- CSUOJ 1862 The Same Game 模拟消消乐
- 旧约圣徒凭什么得救?
- JVM学习(一)之Class类文件结构
- hdu 1028 Ignatius and the Princess III(整数拆分,母函数或dp)
- caffe:如何保存训练模型过程中的日志?
- 【Leetcode】3Sum