标签:
题意:给出一个字典,每条包含两个字符串a和b,空一行给出若干查询,查询给出b求a。
解法:map乱搞……据说是个字典树……并不会字典树……TAT
一直在T……看题解改了一些函数……长姿势了……不过应该是数据加强了的样子……关闭了cincout的同步流……快了不少TUT
代码:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long
using namespace std;
map <string, string> m;
int main()
{
ios :: sync_with_stdio(false);
string s1;
while(getline(cin, s1))
{
if(s1.size() == 0)
break;
string s2, s3;
int i = s1.find_first_of(‘ ‘);
s2 = s1.substr(0, i);
int j = s1.find_first_not_of(‘ ‘, i);
s3 = s1.substr(j, s1.length() - j);
m[s3] = s2;
}
string s;
while(cin >> s)
{
int i = m.count(s);
if(i > 0)
cout << m[s] << endl;
else
cout << "eh" << endl;
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/Apro/p/4531421.html