题解 | #记票统计#
记票统计
http://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main()
{
int d;
while(cin>>d)
{
map<string,int>mp;
vector<string>vec;
int nregur=0;
while(d--)
{
string c;
cin>>c;
mp[c]=0;
vec.push_back(c);
}
cin>>d;
while(d--)
{
string str;
cin>>str;
if(mp.count(str))
{
int v=mp.find(str)->second;
v++;
mp[str]=v;
}
else
{
nregur++;
}
}
for(int i=0;i<vec.size();i++)
{
string s=vec.at(i);
int c=0;
if(mp.count(s))
{
c=mp.find(s)->second;
}
cout<<s<<" : "<<c<<endl;
}
cout<<"Invalid"<<" : "<<nregur<<endl;
}
return 0;
}