P2264 love letter, p2264 love letter

Source: Internet
Author: User

P2264 love letter, p2264 love letter
Background

A good love letter requires the writer's full commitment. Lin_toto looked at the cute slow rice and tried to confess to her, but he did not know whether his love letter could touch her. Now he will ask you to help him with the love letter.

Description

To help lin_toto, we define a standard value to quantify the quality of love letters. The method for judging the moving value is as follows:

1. if a single sentence in a love letter contains a specific word in the given vocabulary list, the value of emotion is added to 1. However, the moving values of each word in the same sentence are not overlapped and different words are not affected. Make sure that the entered words are not repeated.

2. Each sentence is bounded by an English ending.

3. The full text is case insensitive.

Input/Output Format

Input Format:

 

The first row contains a number n, indicating the number of words in the vocabulary list that lead to the increase in the value of motion. The next n rows are given words, with one row. Make sure that the word only contains English letters.

The last line is the body of the love letter, which must contain only the following characters: English letters, numbers, spaces, English commas (,), and English periods (periods.

 

Output Format:

 

A digit g Represents the emotion of a love letter.

 

Input and Output sample input sample #1:
3lovesomuchI love you so much.
Output sample #1:
3
Description

For all data, ensure that 1 ≤ n, m, k ≤ 100. Each word cannot exceed 50 characters, and the full text cannot exceed 1000 characters.

 

A few fake questions are under pressure ,,

First write set,

It seems like a good thing,

In other words.

First, convert all the characters to uppercase,

Then use a set for maintenance.

 

 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<set> 6 using namespace std; 7 const int MAXN=300001; 8 inline void read(int &n) 9 {10     char c=getchar();bool flag=0;n=0;11     while(c<'0'||c>'9')    c=='-'?flag=1,c=getchar():c=getchar();12     while(c>='0'&&c<='9')    n=n*10+(c-48),c=getchar();if(flag==1)n=-n;13 }14 set<string>key,happen;15 int n;16 int ans=0;17 int main()18 {19     read(n);20     for(int i=1;i<=n;i++)21     {22         string s;cin>>s;23         transform(s.begin(), s.end(), s.begin(), ::toupper);24         key.insert(s);25     }26     char c=getchar();27     string now;28     while(scanf("%c",&c)==1)29     {30          now;31         if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))32         {33             if(c>='a'&&c<='z')34             c=c+'A'-'a';35             now+=c;36         }37         else38         {39             if(!now.empty())40             {41             //    cout<<now<<endl;42                 if(key.find(now)!=key.end())43                     happen.insert(now);44                 now.clear();45             }46             if(c=='.')47             {48                 ans+=happen.size();49                 happen.clear();50             }51         }52     }53     printf("%d",ans);54     return 0;55 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.