2015'12杭电新生赛1001 The Country List

题解:

水题不解释

代码

#include <bits/stdc++.h>
#include <cstdio>
#include <queue>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <bitset>
#define MAX 100000
#define LL long long
using namespace std;
int cas=1,T,n;
char word[110][30];
int cmp(int x,int y)
{
    int sum=0;
    for(int i=0;word[x][i]&&word[y][i];i++)
        if(tolower(word[x][i])==tolower(word[y][i])) 
            sum++;
    return sum;
}
int vis[110];

int main()
{
    //freopen("in","r",stdin);
    //scanf("%d",&T);
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++) 
            scanf("%s",word[i]);
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++)
            for(int j=i+1;j<n;j++)
            {
                if(strlen(word[i])==strlen(word[j])&&cmp(i,j)>2) 
                    vis[i]=vis[j]=1;
            }
        int countt=0;
        for(int i=0;i<n;i++) if(vis[i]) countt++;
        printf("%d\n",countt);
    }
    return 0;
}

题目

The Country List

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Problem Description

As the 2010 World Expo hosted by Shanghai is coming, CC is very honorable to be a volunteer of such an international pageant. His job is to guide the foreign visitors. Although he has a strong desire to be an excellent volunteer, the lack of English 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 two countries’ names have the same length and there are more than 2 same letters in the same position of each word, CC cannot distinguish them. For example: Albania and AlgerIa have the same length 7, and their first, second, sixth and seventh letters are same. So CC can’t distinguish them.
Now he has received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters are case-insensitive.

Input

There are multiple test cases.
Each case begins with an integer n (0 < n < 100) 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 will not exceed 20.
You can assume that no name will show up twice in the list.

Output

For each case, output the number of hard names in CC’s list.

Sample Input

3
Denmark
GERMANY
China
4
Aaaa
aBaa
cBaa
cBad

Sample Output

2
4

你可能感兴趣的:(2015'12杭电新生赛1001 The Country List)