The Country List(杭电12月比赛)
来源:互联网 发布:云计算 校园招聘 编辑:程序博客网 时间:2024/06/16 13:13
The Country List
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2558 Accepted Submission(s): 603
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<string.h>#include<stdio.h>using namespace std;//每次只比较一次,如果一个单词和下面的几个一样时。注意每个单词只比较一次//如果分不清就 跳到下一个单词比较int main(){ int n; char dc[105][25]; int len[105]={0}; while(cin>>n) { for(int i=0;i<n;i++) { scanf("%s",dc[i]); len[i]=strlen(dc[i]); for(int k=0;k<len[i];k++) dc[i][k]=tolower(dc[i][k]); } int ans=0; for(int i=0;i<n;i++) { int flag=0; for(int j=0;j<n;j++) { if(len[i]==len[j]&&i!=j) { int temp=0; for(int k=0;k<len[i];k++) { if(dc[i][k]==dc[j][k]) temp++; if(temp>2) { flag=1; break; } } if(flag)break; } } ans+=flag; } cout<<ans<<endl; } return 0;}
0 0
- The Country List(杭电12月比赛)
- 2015'12杭电新生赛1001 The Country List
- 【杭电2015年12月校赛A】【水题 暴力】The Country List 多少个名字与其它名字more than 2位置字符相同
- hdu 计算机学院大学生程序设计竞赛(2015’12)The Country List
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
- 计算机学院大学生程序设计竞赛(2015’12)The Country List(水题)
- 计算机学院大学生程序设计竞赛(2015’12)1001 The Country List
- Hackerrank Connect the country
- hdoj3596杭电比赛2(1004)
- 杭电 1285 确定比赛名次
- 杭电1285确定比赛名次
- 杭电1285确定比赛名次
- 杭电-1285确定比赛名次(topo)
- 【杭电】[1285]确定比赛名次
- 【杭电1285】确定比赛名次
- 杭电1285确定比赛名次
- The Psychology of Cross Country
- The Psychology of Cross Country
- HTML中 &emsp等空格的区别
- MediaPlayer播放assert目录下的音频文件
- Android read write json
- 关于ibatis insert返回值
- unity playmaker player
- The Country List(杭电12月比赛)
- 程序员技术练级攻略
- 如何一夜之间成为一个牛的软件开发者(转自一个国外的牛人)
- ios7上实现UIVisualEffectView效果
- 【LEETCODE】12-Integer to Roman
- 理解java线程状态
- Gson 源码分析 总结
- Select执行顺序
- 忽略performSelector在ARC下的警告