zoukankan      html  css  js  c++  java
  • 蛋疼的英语(set)

    蛋疼的英语

    Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
    Total Submission(s) : 23   Accepted Submission(s) : 12

    Font: Times New Roman | Verdana | Georgia

    Font Size:

    Problem Description

    jxust_acm 队的同学都知道Xianbin5的英语特别差,因而他每次比赛都要队友来给他翻译题目,然而现在队友回家了,他为了提高英语,决定看一篇很长的英文文章, 文章有N个单词(0<N<=50000),但是他的词汇量只有M个单词(0<M<=5000)。在看文章的过程中,如果遇到他不 会的单词,那么他就会去查字典,查过的单词他会了,那么以后遇到就不用再查了。现在给出文章和Xianbin5已经掌握的单词。让求他最小要查字典的次 数。

    Input

    含多组样例(小于5组),每组样例为:
    首先给出N和M,用空格分开。
    然后给出一行英文其中包含N个单词,每个单词由小写字母组成且长度小于20,单词之间用空格分开。
    接下来M行分别是xianbin5会的单词(每个单词由小写字母组成且长度小于20,而且每个单词各不相同)。

    Output

    对于每组样例输出他最小要查词典的次数。

    Sample Input

    5 4
    i love math and acm
    i
    love
    and
    math
    8 1
    can you find grandparents can you answers me 
    me
    

    Sample Output

    1
    5
    

    Author

    jxust_acm

    Source

    xianbin5
    //昨天看到这题的第一反应是用字符串hash,问题是不会字符串hash,
    //就临时去学了下set容器,呵呵

    #include <iostream>
    #include <stdio.h>

    #include<string>
    #include <string.h>
    #include <algorithm>
    #define N 10001
    #include <set>
    using namespace std;
    int main()
    {
        int n,m;
        string str;
        int nt;
        while(cin>>n>>m)
        { set<string> S;
          nt=0;
            while(n--)
            {
                cin>>str;
                S.insert(str);
            }
            while(m--)
            {
                cin>>str;
                if(S.find(str)!=S.end())
                 nt++;
            }
           cout<<S.size()-nt<<endl;
        }
    }

  • 相关阅读:
    caffe_实战之两个简单的例子(物体分类和人脸检测)
    《Caffe下跑AlxNet之数据处理过程》
    git使用小结
    说好的博客
    C++入门学习
    第一篇 一步一步看透C++
    第一百六十三节,jQuery,基础核心
    第一百六十二节,jQuery入门介绍
    第一百六十一节,封装库--JavaScript,完整封装库文件
    第一百六十节,封装库--JavaScript,ajax注册表单到数据库
  • 原文地址:https://www.cnblogs.com/372465774y/p/2606020.html
Copyright © 2011-2022 走看看