前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ZOJ 80ers' Memory

ZOJ 80ers' Memory

作者头像
ShenduCC
发布2018-04-27 11:20:00
5470
发布2018-04-27 11:20:00
举报
文章被收录于专栏:算法修养算法修养

80ers' Memory


Time Limit: 1 Second      Memory Limit: 32768 KB


I guess most of us are so called 80ers, which means that we were born in the 1980's. This group of people shared a lot of common memories. For example, the Saint Seiya, the YoYo ball, the Super Mario, and so on. Do you still remember these?

Input

There will be ONLY ONE test case.

The test case begins with a positive integer N, (N < 100). Then there will be N lines each containing a single word describing a keyword of the typical 80ers' memories. Each word consists of letters, [a-zA-Z], numbers, [0-9], and the underline, '_'. The length of each word would be no more than 20. Then one line follows with a positive integer K, (K < 100). The last part of the test case will be K lines. The i-th line contains the keywords given by the i-th person and starts with a positive integer Ni. Then there will be Ni words separated by white spaces. Each of these words has no more than 20 characters. All the words are case sensitive.

Output

For each of these K people, you are asked to count the number of typical 80ers' keywords on his/her list and output it in a single line.

Sample Input

代码语言:javascript
复制
4
Saint_Seiya
YoYo_ball
Super_Mario
HuLuWa
3
2 Saint_Seiya TiaoFangZi
1 KTV
3 HuLuWa YOYO_BALL YoYo_ball

Sample Output

代码语言:javascript
复制
1
0
2
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <string>

using namespace std;
int n,k,m;
map<string,int> a;
string b[105];
int main()
{
    scanf("%d",&n);
    string s;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        a[s]=1;
    }
    scanf("%d",&k);
    int ans=0;
    for(int i=1;i<=k;i++)
    {
        ans=0;
        scanf("%d",&m);
        for(int j=1;j<=m;j++)
        {
            cin>>s;
            if(a[s]!=0)
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-02-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档