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
查找单词是否相同(相同的条件 长度相同,且有三个相同位置以上的有相同字母)
用set存一存就好了
#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 long
using 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计算机学院大学生程序设计竞赛(2015’12)The Country List的更多相关文章

  1. hdu 计算机学院大学生程序设计竞赛(2015’11)

    搬砖 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...

  2. HDU计算机学院大学生程序设计竞赛(2015’12)Happy Value

    Problem Description In an apartment, there are N residents. The Internet Service Provider (ISP) want ...

  3. HDU计算机学院大学生程序设计竞赛(2015’12)The Magic Tower

    Problem Description Like most of the RPG (role play game), “The Magic Tower” is a game about how a w ...

  4. 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排

    1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  5. 计算机学院大学生程序设计竞赛(2015’12)Study Words

    Study Words Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  6. 计算机学院大学生程序设计竞赛(2015’12)Polygon

    Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  7. 计算机学院大学生程序设计竞赛(2015’12)The Country List

    The Country List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words

    #include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...

  9. 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower

    #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...

随机推荐

  1. xftp permission is not allowed

    上传文件时出现此项错误: permission is not allowed, 原因: 1.可能vsfptd没有配置好 写权限没有开启 2.可能是当前的目录权限,上传的用户不具有: 比如:用户hado ...

  2. 手动编译安装tmux

    tmux的好处就不多说了,总之是多屏管理的神器.通常我们用系统通用的安装方式可以安装到tmux,但有时候,安装到的可能不是我们所需要的版本,又或者软件源里面没有带tmux.这个时候就需要手动编译安装了 ...

  3. java中用正则表达式判断中文字符串中是否含有英文或者数字

    public static boolean includingNUM(String str)throws  Exception{ Pattern p  = Pattern.compile(" ...

  4. php学习笔记-关联数组

    传统的数组定义方法如下: <?php $names[0]= 'chinese'; $names[1]= 'math'; $names[2]= 'english'; echo $names[2]; ...

  5. EZOJ #73

    传送门 分析 我们知道如果对于模数$P$有$gcd(x,P) = 1$则$x$一定有且仅有一个逆元,可以表示为 $x \equiv \frac{y}{1} (mod P)$ 即为$xy \equiv ...

  6. ZROI2018提高day4t3

    传送门 分析 我们假设如果一个点是0则它的值为-1,如果一个点是1则值为1,则一个区间的答案便是max(pre[i]+sur[i]),这里的pre[i]表示此区间i点和它之前的的前缀的最大值,sur[ ...

  7. poj3734 Blocks

    传送门 题目大意 有n个方块,有1,2,3,4四种颜色对其进行染色,求1,2颜色的方块个数均为偶数的方案数对10007取模的值. 分析 我们假设1表示这个颜色个数是奇数,0表示是偶数,所以对于所有状态 ...

  8. Luogu 3205 [HNOI2010]合唱队

    初赛滚粗的我含着眼泪写代码…… 设$f_{l, r, 0/1}$表示$[l, r]$的区间的队伍排列好,且最后一个插进去的在左边$(0)$/右边$(1)$的方案数,那么有初态$f_{i, i, 0} ...

  9. etl 获取列数据类型

    QueryInfo info = new QueryInfo(); info.CustomSQL = @" select column_name, data_type, data_preci ...

  10. Hive安装及配置

    第一步:下载hive并解压 tar zxvf hive-0.8.1-bin.tar.gz 重命名: mv hive-0.8.1-bin hive 给权限:chown hadoop:hadoop hiv ...