F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Spring festival couplets

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 347    Accepted Submission(s): 183


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
6 ABCCCDA LLLMNNO DEZZZBF AAABCCD KKKXPPQ AAA
 

Sample Output
4
 

Author
dandelion
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-06 18:55:00, Gzip enabled