这道题是用STL里面的map过的(POJ的编译器找不到unordered_map),非常慢,不过勉强过了。
2503 | Accepted | 14792K | 2141MS | G++ | 918B |
/*
ID: thestor1
LANG: C++
TASK: poj2503
*/
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cassert>
#include <sstream>
using namespace std;
int main()
{
std::ios::sync_with_stdio(false);
string line, english, foreign;
map<string, string> dict;
while (getline(cin, line))
{
if (line == "")
{
break;
}
stringstream ss(line);
ss >> english;
ss >> foreign;
// cout << "english:" << english << ", foreign:" << foreign << endl;
dict[foreign] = english;
}
while (cin >> foreign)
{
if (dict.find(foreign) != dict.end())
{
cout << dict[foreign] << endl;
}
else
{
cout << "eh" << endl;
}
}
return 0;
}