View Code of Problem 443

#include<iostream>
#include<unordered_map>
using namespace std;
int main()
{
	unordered_map<string,int> mp;
	int t;
	cin >> t;
	while(t --)
	{
		string name;
		cin >> name;
		mp[name] ++;
	}
	int cnt;
	cin >> cnt;
	while(cnt --)
	{
		int m = 0;
		int n;
		cin >> n;
		for(int i = 0;i < n;i ++)
		{
			string s;
			cin >> s;
			if(mp[s] > 0) m ++;
		}
		cout << m << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 443