ZOJ#3207:80ers' Memory

本文介绍了一个关于80后共同记忆的小程序挑战,通过比对输入的关键字来计数并输出那些能唤起80后集体回忆的经典元素数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Memory Limit: 32768KB
64bit IO Format: %lld & %llu

Description

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

4
Saint_Seiya
YoYo_ball
Super_Mario
HuLuWa
3
2 Saint_Seiya TiaoFangZi
1 KTV
3 HuLuWa YOYO_BALL YoYo_ball

Sample Output

1
0
2

Source
The 6th Zhejiang Provincial Collegiate Programming Contest

AC代码如下:

#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    string a[101],t;
    int N,k;
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>a[i];
    cin>>k;
    for(int i=0;i<k;i++)
    {
        int w=0,f;
        cin>>f;
        while(f--)
        {
            cin>>t;
            for(int i=0;i<N;i++)
            {
                if(t==a[i])
                    w++;
                else continue;
            }   
        }   
        cout<<w<<endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值