您的位置:首页 > 其它

HDU 1880 魔咒词典

2013-06-30 16:24 344 查看
用两个map,一个用来存意思--魔咒,一个用来存魔咒-
4000
-意思;

我用c++提交,结果超内存,后来用G++提交,就过了……

#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
int i,j,n;
string st,str;
map<string ,string> m;
map<string,string> mm;
while(1)
{
cin>>st;
if(st=="@END@")
break;
cin.get();
getline(cin,str);
mm[st]=str;
m[str]=st;
}
cin>>n;
cin.get();
while(n--)
{

getline(cin,str);
if(mm[str]!="")
cout<<mm[str]<<endl;
else if(m[str]!="")
{
string k=m[str];
for(i=1;i<k.size()-1;i++)
cout<<k[i];
cout<<endl;
}

else
cout<<"what?"<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: