计算机学院大学生程序设计竞赛(2015’12)The Country List(水题)
来源:互联网 发布:广联达定额计价软件 编辑:程序博客网 时间:2024/06/06 18:21
The Country List
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2516 Accepted Submission(s): 592
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.
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.
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
3DenmarkGERMANYChina4AaaaaBaacBaacBad
Sample Output
24
#include <iostream>#include <cstring>#include <cstdio>#include <cstdlib>#include <cmath>#include <algorithm>#include <queue>#include <stack>#include <set>#include <map>#include <list>#define LL long long#define INF 0x3f3f3f3fusing namespace std;char s[110][25];int len[110];int main(){ int n; while(~scanf("%d",&n)) { int ant = 0; for(int i=0; i<n; i++) scanf("%s",s[i]), len[i] = strlen(s[i]); for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(i!=j) { if(len[i] == len[j]) { int num = 0; for(int k = 0; k < len[j]; k++) { if(s[i][k] == s[j][k] || s[i][k] == s[j][k] + 32 ||s[i][k] == s[j][k] - 32) num++; } if(num >2) { ant++; break; } } } } } cout<<ant<<endl; } return 0;}
0 0
- 计算机学院大学生程序设计竞赛(2015’12)The Country List(水题)
- hdu 计算机学院大学生程序设计竞赛(2015’12)The Country List
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
- 计算机学院大学生程序设计竞赛(2015’12)1001 The Country List
- 计算机学院大学生程序设计竞赛(2015’12)(STL )
- 计算机学院大学生程序设计竞赛(2015’12)Polygon
- 计算机学院大学生程序设计竞赛(2015’12)Happy Value
- 计算机学院大学生程序设计竞赛(2015’12)Bitwise Equations
- 计算机学院大学生程序设计竞赛(2015’12)01 Matrix
- 计算机学院大学生程序设计竞赛(2015’12)Pick Game
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
- 计算机学院大学生程序设计竞赛(2015’12)Bitwise Equations
- 计算机学院大学生程序设计竞赛(2015’12)The Magic Tower(水~~~)
- hdu 计算机学院大学生程序设计竞赛(2015’12)The Magic Tower
- 计算机学院大学生程序设计竞赛(2015’12)The collector’s puzzle
- 计算机学院大学生程序设计竞赛(2015’12)The Magic Tower
- 计算机学院大学生程序设计竞赛(2015’12)The collector’s puzzle
- 计算机学院大学生程序设计竞赛(2015’12)1009 The Magic Tower
- CentOS系统中Firefox浏览器的flash player安装
- lvs+keepalived 负载均衡realserver.sh脚本
- 22.UITableViewCell根据Cell的内容自适应
- 编写高质量iOS 与OSX 代码的52个有效方法之内存管理
- [Android][Build Problems] failed to find build tools revision & failed to find target android 等问题解决
- 计算机学院大学生程序设计竞赛(2015’12)The Country List(水题)
- Memcached概念及使用原理
- 【C++】深度探索C++对象模型之站在对象模型的顶端
- 【重走普及路】【经典算法】约瑟夫问题
- CentOS 6.5 Ruby源码安装
- 第六届福建省大学生程序设计竞赛 Problem C Knapsack problem【背包问题】
- Linux Shell 逐行读取文件 ( txt , sh , csv等)
- Spring之访问(消费)WebService
- 数据中心架构部署