HDU Computer College College Student Program Design Contest (') the country List

Source: Internet
Author: User

The country List

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 2598 Accepted Submission (s): 615

Problem Descriptionas the World Expo hosted by Shanghai are coming, CC is very honorable to BES a volunteer of such an International pageant. The foreign visitors. Although he has a strong desire to is an excellent volunteer, the lack of 中文版 makes him annoyed for a long time.
Some countries ' names look so similar that he can ' t distinguish them. Such As:albania and Algeria. If the countries ' names has the same length and there is more than 2 same letters in the same position of each word, CC Cannot distinguish them. For Example:albania and AlgerIa has the same length 7, and their first, second, sixth and seventh letters are same. So CC can ' t distinguish them.
Now he have received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters is case-insensitive. Inputthere is multiple test cases.
Each case begins with a integer n (0 < n <) indicating the number of countries in the list.
The next n lines each contain a country ' s name consisted by ' a ' ~ ' Z ' or ' a ' ~ ' Z '.
Length of each word would not exceed 20.
You can assume that no name would show up twice in the list. Outputfor each case, output the number of hard names in CC ' s list. Sample input3denmarkgermanychina4aaaaabaacbaacbad sample Output24 Find if the words are the same (the same condition length is the same, And have three of the same position above the same letter) with the set to save one.
#include <stdio.h>//#include <bits/stdc++.h> #include <string.h> #include <iostream> #include <math.h> #include <sstream> #include <set> #include <queue> #include <map> #include < vector> #include <algorithm> #include <limits.h> #define INF 0x3fffffff#define inf 0x3f3f3f3f#define Lson L,m,rt<<1#define Rson m+1,r,rt<<1|1#define LL long long#define ULL unsigned long longusing namespace Std;int n        ; string ss[100];set<string> q;int main () {while (cin>>n) {int i,j;        for (i=0; i<n; i++) {cin>>ss[i];                } for (i=0; i<n; i++) {for (j=0; j<n; J + +) {int sum=0;                if (i==j) continue;                    if (Ss[i].length () ==ss[j].length ()) {for (int z=0; z<ss[i].length (); z++) {if (ss[i][z]==ss[j][z]| |            ABS (Ss[i][z]-ss[j][z]) ==32)            {sum++; }} if (sum>2) {//cout<<ss[i]<                        < "" <<ss[j]<<endl;                    Q.insert (Ss[j]);        }}}} cout<<q.size () <<endl;    Q.clear (); } return 0;}

  

HDU Computer College College Student Program Design Contest (') the country List

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.