zoukankan      html  css  js  c++  java
  • ZOJ 3207 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
    

    Author: GAO, Fei
    Source: The 6th Zhejiang Provincial Collegiate Programming Contest

    map秒过了。。。

    水题。。

    #include<stdio.h>
    #include<iostream>
    #include<string.h>
    #include<string>
    #include<algorithm>
    #include<map>
    using namespace std;
    map<string,int>mp;
    int main()
    {
        int n,k;
        int m;
        string str;
        while(scanf("%d",&n)!=EOF)
        {
            mp.clear();
            while(n--)
            {
                cin>>str;
                if(mp[str]==0)mp[str]=1;
            }
            int ans;
            scanf("%d",&k);
            while(k--)
            {
                scanf("%d",&m);
                ans=0;
                while(m--)
                {
                    cin>>str;
                    ans+=mp[str];
                }
                printf("%d\n",ans);
            }
        }
        return 0;
    }
  • 相关阅读:
    刨根问底 | Elasticsearch 5.X集群多节点角色配置深入详解【转】
    ElasticSearch 内存那点事【转】
    Zookeeper之Zookeeper的Client的分析【转】
    Zookeeper之Zookeeper底层客户端架构实现原理(转载)
    elasticsearch 性能调优
    ElasticSearch性能优化策略【转】
    elasticsearch中 refresh 和flush区别【转】
    我理解的朴素贝叶斯模型【转】
    (转)Intellij IDEA 快捷键整理
    使用Mongo dump 将数据导入到hive
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2706130.html
Copyright © 2011-2022 走看看