Hdu 2651 Spring festival couplets

Source: Internet
Author: User
Tags cmath

Hdu 2651 Spring festival couplets

 

Spring festival couplets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 194 Accepted Submission (s): 82



Problem Description When the spring festival is coming, people always paste spring festival couplets onto the wall. now dandelion's father has bought several spring festival couplets, he wants to know how many pairs of spring festival couplets can been consisted with these spring festival couplets. as we know, spring festival couplets are carefully balanced. such as AABBCCDD can only be matched with AABBCCDD or BBDDEEFF or AABBAABB...

Input A number n stands for the number of the spring festival couplets. (2 ≤n ≤ 110000)
Then n lines, each line contains a string made by capital letters. Such as AABBCCDD, AABBCCD. The length of the string will not exceed 8.
Output For every case, print the number of pairs can be made by these spring festival couplets.
Sample Input
6ABCCCDALLLMNNODEZZZBFAAABCCDKKKXPPQAAA

Sample Output
4

The question is quite clear about couplets. If you can pair them, you can pair them and ask how many pairs you can match. You can use map ing to map them directly. Each time you see the same pattern as the current string, it appears several times, after the input is complete, the statistics are complete and will not be repeated. However, during the afternoon competition, I had no idea why I was so upset and I was not able to write water questions. I 'd better go home and wash and sleep.
#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include #include
      #include 
       
        #using namespace std;char s[10];int main(){ int n; while(~scanf(%d,&n)) { map
        
         ss; int ans=0; for(int i=0;i
         
           
          

 

 

 

 

 

 

 

Related Article

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.