map和vector双管齐下
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int main() {
int n1;
while(cin>>n1){
vector<string> v(n1);
map<string,int> m;
m.insert(make_pair("Invalid", 0));
string temp;
for(int i = 0;i<n1;i++){
cin>>temp;
v[i]=temp;
m.insert(make_pair(temp, 0));
}
v.push_back("Invalid");
int n2;
cin>>n2;
for(int j = 0;j<n2;j++){
cin>>temp;
auto it=m.find(temp);
if(it!=m.end())m[temp]++;
else m["Invalid"]++;
}
for(auto it = v.begin();it!=v.end();it++){
cout<<(*it)<<' '<<':'<<' '<<m[(*it)]<<endl;
}
}
}