rt.
评测记录
本蒟蒻使用STL,不喜勿喷。
本地测,洛谷在线IDE测都是没有问题的。而且我提交是删了 freopen 的。
code:
#include <iostream>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
int main()
{
map<string,string> mp;
string anc,son,sch;
char ch='\0';
while(ch!='$')
{
ch=getchar();
if(ch=='$')break;
if(ch=='#')
{
cin>>anc;
if(mp.find(anc)==mp.end())
{
mp[anc]="######";
}
}
else if(ch=='+')
{
cin>>son;
mp[son]=anc;
}
else
{
cin>>sch;
while(mp[sch]!="######")
{
sch=mp[sch];
}
cout<<sch<<endl;
}
getchar();
}
}