Zju 1109 Language of FatMouse 解题报告

#include < iostream >
#include
< string >
#include
< vector >
#include
< algorithm >
using namespace std;

struct ZD
... {
stringyc,ys;
}
;

vector
< ZD > v;

bool cmp(ZDs,ZDt)
... {
returns.ys<t.ys;
}


string binSearch( string s)
... {
intlow=0,high=v.size()-1,mid;
while(low<=high)
...{
mid
=(low+high)/2;
if(v[mid].ys==s)returnv[mid].yc;
if(v[mid].ys>s)
high
=mid-1;
else
low
=mid+1;
}

return"eh";
}


void init()
... {
ZDt;
strings;

while(true)
...{
getline(cin,s);
if(s=="")break;
inti=s.find("");
t.yc
=s.substr(0,i);
t.ys
=s.substr(i+1);
v.push_back(t);
}


sort(v.begin(),v.end(),cmp);
}


bool run()
... {
stringts;
if(!(cin>>ts))returnfalse;

cout
<<binSearch(ts)<<endl;
returntrue;
}


int main()
... {
init();
while(run());
return0;
}


你可能感兴趣的:(language)