结构之美――字典树 - 小熊不去实验室 - 博客频道 - CSDN.NET



Message Flood

时间限制(普通/Java):2000MS/6000MS          运行内存限制:65536KByte
总提交:139            测试通过:27

描述

Well, how do you feel about mobile phone? Your answer would probably be something like that "It's so convenient and benefits people a lot". However , if you ask Merlin this question on the New Year's Eve , he will definitely answer " What a trouble! I have to keep my fingers moving on the phone the whole night , because I have so many greeting messages to send !" . Yes , Merlin has such a long name list of his friends , and he would like to send a greeting message to each of them . What's worse , Merlin has another long name list of senders that have sent message to him , and he doesn't want to send another message to bother them ( Merlin is so polite that he always replies each message he receives immediately ). So , before he begins to send messages , he needs to figure to how many friends are left to be sent . Please write a program to help him.
 Here is something that you should note. First , Merlin's friend list is not ordered , and each name is alphabetic strings and case insensitive . These names are guaranteed to be not duplicated . Second, some senders may send more than one message to Merlin , therefore the sender list may be duplicated . Third , Merlin is known by so many people , that's why some message senders are even not included in his friend list.

输入

 There are multiple test cases . In each case , at the first line there are two numbers n and m ( 1<=n , m<=20000) , which is the number of friends and the number of messages he has received . And then there are n lines of alphabetic strings ( the length of each will be less than 10 ) , indicating the names of Merlin's friends , one pre line . After that there are m lines of alphabetic string s ,which are the names of message senders .
 The input is terminated by n=0.

首先输入两个数m(总朋友数量),n(发送的信息数量),

接着:一系列字符串前m个表示朋友名字

n表示已发送信息的数量

输出:还有几个朋友必须发送信息

 

输出

 For each case , print one integer in one line which indicates the number of left friends he must send .

样例输入

5 3
Inkfish
Henry
Carp
Max
Jericho
Carp
Max
Carp
0

样例输出

3


Read full article from 结构之美――字典树 - 小熊不去实验室 - 博客频道 - CSDN.NET


No comments:

Post a Comment

Labels

Algorithm (219) Lucene (130) LeetCode (97) Database (36) Data Structure (33) text mining (28) Solr (27) java (27) Mathematical Algorithm (26) Difficult Algorithm (25) Logic Thinking (23) Puzzles (23) Bit Algorithms (22) Math (21) List (20) Dynamic Programming (19) Linux (19) Tree (18) Machine Learning (15) EPI (11) Queue (11) Smart Algorithm (11) Operating System (9) Java Basic (8) Recursive Algorithm (8) Stack (8) Eclipse (7) Scala (7) Tika (7) J2EE (6) Monitoring (6) Trie (6) Concurrency (5) Geometry Algorithm (5) Greedy Algorithm (5) Mahout (5) MySQL (5) xpost (5) C (4) Interview (4) Vi (4) regular expression (4) to-do (4) C++ (3) Chrome (3) Divide and Conquer (3) Graph Algorithm (3) Permutation (3) Powershell (3) Random (3) Segment Tree (3) UIMA (3) Union-Find (3) Video (3) Virtualization (3) Windows (3) XML (3) Advanced Data Structure (2) Android (2) Bash (2) Classic Algorithm (2) Debugging (2) Design Pattern (2) Google (2) Hadoop (2) Java Collections (2) Markov Chains (2) Probabilities (2) Shell (2) Site (2) Web Development (2) Workplace (2) angularjs (2) .Net (1) Amazon Interview (1) Android Studio (1) Array (1) Boilerpipe (1) Book Notes (1) ChromeOS (1) Chromebook (1) Codility (1) Desgin (1) Design (1) Divide and Conqure (1) GAE (1) Google Interview (1) Great Stuff (1) Hash (1) High Tech Companies (1) Improving (1) LifeTips (1) Maven (1) Network (1) Performance (1) Programming (1) Resources (1) Sampling (1) Sed (1) Smart Thinking (1) Sort (1) Spark (1) Stanford NLP (1) System Design (1) Trove (1) VIP (1) tools (1)

Popular Posts