HDU计算机学院大学生程序设计竞赛(2015’12)The Country List
Problem Description
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.
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.
#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的更多相关文章
- hdu 计算机学院大学生程序设计竞赛(2015’11)
搬砖 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...
- HDU计算机学院大学生程序设计竞赛(2015’12)Happy Value
Problem Description In an apartment, there are N residents. The Internet Service Provider (ISP) want ...
- 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 ...
- 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排
1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
Study Words Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- 计算机学院大学生程序设计竞赛(2015’12)Polygon
Polygon Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
The Country List Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words
#include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...
- 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...
随机推荐
- Call requires API level 7 (current min is 1):(问题解决)
在一个导入的项目里修改加入webView的时候设置缩放属性的设置报错: Call requires API level 7 (current min is 1): android.webkit.Web ...
- C++指针作为函数的参数进行传递时注意的问题
应注意问题: 当指针作为函数的参数进行传递的时候,本质上还是进行的"值传递",也就是复制了一个新的指向该地址的指针变量. 只有在被调函数中,对指针进行引用操作,才可以达到不需要返回 ...
- jquery easyui datagrid/table 右边线显示不全
<table id="dg" style="height:400px"></table> 右边线显示不全 解决:在外面套一个panel, ...
- K-D TREE算法原理及实现
博客转载自:https://leileiluoluo.com/posts/kdtree-algorithm-and-implementation.html k-d tree即k-dimensional ...
- Linux tput命令
一.简介 shell 脚本编写者往往需要能通过一种方法将输出更改为粗体,为其加下划线,实现反向突出显示等,这正是 tput 的用武之地. tput 命令将通过 terminfo 数据库对您的终端会话进 ...
- 属性文件读写测试 PropertiesFileTest
属性文件对于程序的拓展提供了很大的方便,但是什么该怎么去读写,怎么样读写才会最优呢?这里我做了一个简单的测试, 一般而言主要的有三种配置文件,*.ini,*.properties,*.xml,如果有兴 ...
- c# sql省市联动
C# sql省市联动 USE [Book] GO ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ...
- JavaScript 测试和捕捉(try与catch)
JavaScript 测试和捕捉 try 语句允许我们定义在执行时进行错误测试的代码块. catch 语句允许我们定义当 try 代码块发生错误时,所执行的代码块. JavaScript 语句 try ...
- 机器学习基石笔记:11 Linear Models for Classification、LC vs LinReg vs LogReg、OVA、OVO
原文地址:https://www.jianshu.com/p/6f86290e70f9 一.二元分类的线性模型 线性回归后的参数值常用于PLA/PA/Logistic Regression的参数初始化 ...
- 算法训练 数字三角形(DP)
问题描述 (图3.1-1)示出了一个数字三角形. 请编一个程序计算从顶至底的某处的一条路 径,使该路径所经过的数字的总和最大. ●每一步可沿左斜线向下或右斜线向下走: ●1<三角形行数≤100: ...