zoukankan      html  css  js  c++  java
  • ZOJ 80ers' Memory

    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

    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

    #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
    ",ans);
        }
        return 0;
    }


  • 相关阅读:
    shutil的一些基本用法
    python用random产生验证码,以及random的一些其他用法
    hashlib 文件校验,MD5动态加盐返回加密后字符
    python中logging日志基本用法,和进程安全问题
    用递归函数得到目录下的所有文件
    python装饰器
    列表推导式三种模式和生成器
    vue.js响应式原理解析与实现
    Promise详解
    三分钟教你同步 Visual Studio Code 设置
  • 原文地址:https://www.cnblogs.com/dacc123/p/8228561.html
Copyright © 2011-2022 走看看