题目1029:魔咒词典
#include <stdio.h>
#include <iostream>
#include <stack>
#include <string.h>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long LL;
#define MAX 1000001
bool cmp(pair<string, int> a, pair<string, int> b) {
if(a.second != b.second) {
return a.second > b.second;
} else {
return a.first < b.first;
}
}
int main() {
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
string str;
map<string, string> mapp;
while(getline(cin, str)){
if(str != "@END@"){
string str1, str2;
int pos_1 = str.find(']');
str1 = str.substr(1, pos_1 - 1);
str2 = str.substr(pos_1 + 2, str.size() - pos_1 - 2);
//cout << str2 << endl;
mapp[str1] = str2;
mapp[str2] = str1;
}else{
int n;
cin >> n;
getchar();
for(int i = 0; i < n; i++){
string temp;
getline(cin, temp);
int pos_2 = temp.find(']');
if(pos_2 != string::npos){
temp = temp.substr(1, pos_2 - 1);
}
//cout << temp << endl;
if(mapp[temp] != ""){
cout << mapp[temp] << endl;
}else {
cout << "what?" << endl;
//Map进行查找。。。
//if(Map.find(str) == Map.end())
//{
// printf("what?\n");
//}
}
}
break;
}
}
return 0;
}
/**************************************************************
Problem: 1029
User: Crazy_man
Language: C++
Result: Accepted
Time:50 ms
Memory:2584 kb
****************************************************************/